To create an object-based point-and-click mini-game, do the following:
- In the Inspector window, add the Player tag to the Sphere-arrow GameObject.
- Delete the two 3D Cubes and the 3D Capsule-destination from the scene.
- Create three GameObjects – a 3D Cube, a 3D Sphere, and a 3D Cylinder.
- Create a ClickMeToSetDestination C# script class containing the following code:
using UnityEngine;
public class ClickMeToSetDestination : MonoBehaviour
{
private UnityEngine.AI.NavMeshAgent playerNavMeshAgent;
void Start() {
GameObject playerGO = GameObject.FindGameObjectWithTag("Player");
playerNavMeshAgent = playerGO.GetComponent<UnityEngine.AI.NavMeshAgent>();
}
private void OnMouseDown() {
playerNavMeshAgent.SetDestination(transform.position);
}
}
- Add instance objects of the ClickMeToSetDestination C# script class as components to your 3D Cube, Sphere, and Cylinder.
- Run the scene. When you click...