diff --git a/playable/Assets/Scenes/Level2.unity b/playable/Assets/Scenes/Level2.unity index 6fdc234..e69d69b 100644 Binary files a/playable/Assets/Scenes/Level2.unity and b/playable/Assets/Scenes/Level2.unity differ diff --git a/playable/Assets/Scripts/Patrol.cs b/playable/Assets/Scripts/Patrol.cs index 279839c..222d928 100644 --- a/playable/Assets/Scripts/Patrol.cs +++ b/playable/Assets/Scripts/Patrol.cs @@ -11,6 +11,7 @@ public class Patrol : MonoBehaviour { public int direction = 1; private Vector3 startPosition; private int curWait = 0; + private Vector3 move = new Vector3(1, 0.0f ,0.0f); // Use this for initialization void Start () { @@ -25,8 +26,8 @@ public class Patrol : MonoBehaviour { // Update is called once per frame void Update () { Vector3 curPosition = transform.position; - Vector3 move = new Vector3(1, 0.0f ,0.0f); + move = new Vector3(1, 0.0f ,0.0f); move.x *= speed; move *= direction; @@ -45,4 +46,11 @@ public class Patrol : MonoBehaviour { curWait--; } + void OnTriggerStay2D(Collider2D other) { + if (other.tag == "Player") { + Debug.Log(other.name); + other.transform.parent.transform.position += move; + } + + } }