Point-and-click move to object
Another way to choose the destination for our Sphere-arrow
GameObject is by the user clicking on an object on the screen, and then the Sphere-arrow
GameObject moving to the location of the clicked object:
Figure 12.7: Example of point-and-click move to object
Getting ready
This recipe adds to the first recipe in this chapter, so make a copy of that project folder and do your work for this recipe with that copy.
How to do it...
To create an object-based point-and-click mini-game, do the following:
- In the Inspector panel, add the
Player
tag to theSphere-arrow
GameObject. - Delete the two 3D cubes and the 3D
Capsule-destination
from the scene. - Remove the
ArrowNCPMovement
C# script as a component from theSphere-arrow
Game Object. - Create three GameObjects – a 3D cube, a 3D sphere, and a 3D cylinder – and place them in different positions within the terrain.
- On the
NavMeshSurface
component...