Question by
Gohst002 · Jun 14, 2017 at 05:24 AM ·
raycastnavmeshagentraycasthit
MoveToInteraction takes 1 argument
My MoveToInteraction does not work. Could someone help me?
public NavMeshAgent playerAgent;
void Start()
{
playerAgent = GetComponent <NavMeshAgent>();
}
void Update()
{
if (Input.GetMouseButtonDown (0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
{
GetInteraction ();
}
}
public void GetInteraction()
{
Ray interactionRay = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit interactionInfo;
if(Physics.Raycast(interactionRay, out interactionInfo, Mathf.Infinity))
{
GameObject interactedObject = interactionInfo.collider.gameObject;
if (interactedObject.tag == "Interactable Object")
{
interactedObject.GetComponent<Interactable> ().MoveTointeraction(playerAgent);
}
else
{
playerAgent.destination = interactionInfo.point;
}
}
}
Comment
Answer by Derpensson · Jul 26, 2017 at 02:25 PM
Check your interactable script and see if you typod there on public virtual void MoveToInteraction(NavMeshAgent playerAgent) i had mine set to Move"to"Interaction and not "To" that was my problem ^^