diff options
| author | Alee <Alee14498@gmail.com> | 2019-05-31 15:25:28 -0400 |
|---|---|---|
| committer | Alee <Alee14498@gmail.com> | 2019-05-31 15:25:28 -0400 |
| commit | 14b961253ede0e3a84d449149ac623b8f380c27b (patch) | |
| tree | 49ab95429fa02d6f029381cae232eb0f9eec5b10 /Assets/Scripts/PlayerMovement.cs | |
| download | Unicity-14b961253ede0e3a84d449149ac623b8f380c27b.tar.gz Unicity-14b961253ede0e3a84d449149ac623b8f380c27b.tar.bz2 Unicity-14b961253ede0e3a84d449149ac623b8f380c27b.zip | |
Inital commit
Diffstat (limited to 'Assets/Scripts/PlayerMovement.cs')
| -rw-r--r-- | Assets/Scripts/PlayerMovement.cs | 30 |
1 files changed, 30 insertions, 0 deletions
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 <UnityEngine.AI.NavMeshAgent> (); + } + + // 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); + } + } + } +} |
