aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts
diff options
context:
space:
mode:
authorAlee <Alee14498@gmail.com>2019-05-31 15:25:28 -0400
committerAlee <Alee14498@gmail.com>2019-05-31 15:25:28 -0400
commit14b961253ede0e3a84d449149ac623b8f380c27b (patch)
tree49ab95429fa02d6f029381cae232eb0f9eec5b10 /Assets/Scripts
downloadUnicity-14b961253ede0e3a84d449149ac623b8f380c27b.tar.gz
Unicity-14b961253ede0e3a84d449149ac623b8f380c27b.tar.bz2
Unicity-14b961253ede0e3a84d449149ac623b8f380c27b.zip
Inital commit
Diffstat (limited to 'Assets/Scripts')
-rw-r--r--Assets/Scripts/PlayerMovement.cs30
-rw-r--r--Assets/Scripts/PlayerMovement.cs.meta11
2 files changed, 41 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);
+ }
+ }
+ }
+}
diff --git a/Assets/Scripts/PlayerMovement.cs.meta b/Assets/Scripts/PlayerMovement.cs.meta
new file mode 100644
index 0000000..30793c0
--- /dev/null
+++ b/Assets/Scripts/PlayerMovement.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 12d4d72b91b49f045a12f8c1a7cac845
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: