Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created August 30, 2017 17:30
Show Gist options
  • Save unity3dcollege/58e1eaeb268ea87fa29a838f3b0538f7 to your computer and use it in GitHub Desktop.
Save unity3dcollege/58e1eaeb268ea87fa29a838f3b0538f7 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.AI;
public class PlayerBrain : CharacterBrain
{
public PlayerBrain(NavMeshAgent navMeshAgent) : base(navMeshAgent)
{
navMeshAgent.GetComponent<Renderer>().material.color = Color.green;
}
public override void Tick()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo))
{
navMeshAgent.SetDestination(hitInfo.point);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment