Created
August 30, 2017 17:30
-
-
Save unity3dcollege/58e1eaeb268ea87fa29a838f3b0538f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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