Journal 65 — Using Unity, Point and Click Movement

Chris Nielsen
3 min readAug 9, 2021

--

Objective: Add point and click movement to “The Great Fleece”

In the example below from “The Great Fleece”, we need to set up point and click movement.

We need to first create a NavMeshAgent on the Auction House floor. We can access this in the AI → Navigation window. With the Floor Collider game object selected, we can select “Bake”.

The game is set up already with triggers as the player, Darren, makes his way to the vault. So the camera view will switch automatically. Let’s set the Main Camera to the first area. We can do this by temporarily moving the Main Camera to the same folder as where Camera_One is stored, and copy the Transform values to the Main Camera, then move the Main Camera back into the Hierarchy.

Now to set up the Player movement, we can start with a simple 3D capsule, and position the capsule where Darren drops behind the display case.

We can also fix this game object’s name, Tag, Scale, and add a NavMeshAgent component.

Next, we need to add our first C# script for the Player.

Since this is a point and click type movement game, let’s start with some basic pseudocode to describe the first updates: when the user clicks on the location to move, we want to show those coordinates, and also draw a cube.

Refer to Unity Raycast to see several examples.

Now to update the player position, refer to the Unity — Manual: Telling a NavMeshAgent to Move to a Destination (unity3d.com).

And here are the first results. As you can see, the player can pass right through and clip the display cases. We need to remove these objects from the navmesh.

We can do this by selecting the “DetailedModel” which includes the display cases, and select “Static” checkbox in the Inspector. Then we need to clear and do a new bake. As you can see, each display case is now surrounded by a non-walkable surface.

And here are the final results in Playmode, where the Player can no longer walk through the cases.

Thank you for your time!

--

--

Chris Nielsen
Chris Nielsen

Written by Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

No responses yet