Browse Source

added moving platform

master
Joshua Reason 9 years ago
parent
commit
f158859f17
2 changed files with 9 additions and 1 deletions
  1. BIN
      playable/Assets/Scenes/Level2.unity
  2. +9
    -1
      playable/Assets/Scripts/Patrol.cs

BIN
playable/Assets/Scenes/Level2.unity View File


+ 9
- 1
playable/Assets/Scripts/Patrol.cs View File

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

Loading…
Cancel
Save