|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |