From 14b961253ede0e3a84d449149ac623b8f380c27b Mon Sep 17 00:00:00 2001 From: Alee Date: Fri, 31 May 2019 15:25:28 -0400 Subject: Inital commit --- Assets/Scripts/PlayerMovement.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Assets/Scripts/PlayerMovement.cs (limited to 'Assets/Scripts/PlayerMovement.cs') diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs new file mode 100644 index 0000000..c55b7a8 --- /dev/null +++ b/Assets/Scripts/PlayerMovement.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.AI; + +public class PlayerMovement : MonoBehaviour +{ + public LayerMask whatCanBeClickedOn; + + private UnityEngine.AI.NavMeshAgent myAgent; + + // Start is called before the first frame update + void Start() + { + myAgent = GetComponent (); + } + + // Update is called once per frame + void Update() + { + if (Input.GetMouseButtonDown(0)) { + Ray myRay = Camera.main.ScreenPointToRay (Input.mousePosition); + RaycastHit hitInfo; + + if(Physics.Raycast (myRay, out hitInfo, 100, whatCanBeClickedOn)) { + myAgent.SetDestination (hitInfo.point); + } + } + } +} -- cgit v1.2.3