Error seems to be at Ray object declaration or upon calling GetInteraction() method. Well I think so.
// Use this for initialization
void Start()
{
playerAgent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
GetInteraction();
}
void GetInteraction()
{
Ray interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit interactionInfo;
if (Physics.Raycast(interactionRay, out interactionInfo, 100))
{
GameObject interactionObject = interactionInfo.collider.gameObject;
if (interactionObject.tag == "Interactable Object")
{
Debug.Log(interactionInfo.collider.gameObject.name);
}
else
{
playerAgent.destination = interactionInfo.point;
}
}
}
I’ve set the canvas as an UI and EventSystem was created
I am following this guy: Level Design and Click to Move | Making a Simple RPG - Unity 5 Tutorial (Part 1) - YouTube