// Update is called once per frame void Update() { // Debug.Log(speed); float x = transform.position.x; if (x < -200) { // Debug.Log("here"); transform.Translate(new Vector3(400, 0, 0), Space.World); hazard.Activate(); } transform.Translate(-new Vector3(speed * Time.deltaTime, 0, 0), Space.World); }
// Update is called once per frame void Update() { Transform t = g1.transform; float x = g1.transform.position.x; if (x < -200) { // Debug.Log("here"); t.Translate(new Vector3(400, 0, 0), Space.World); hazard1.Activate(); } t.Translate(-new Vector3(speed * Time.deltaTime, 0, 0), Space.World); t = g2.transform; x = g2.transform.position.x; if (x < -200) { // Debug.Log("here"); t.Translate(new Vector3(400, 0, 0), Space.World); hazard2.Activate(); } t.Translate(-new Vector3(speed * Time.deltaTime, 0, 0), Space.World); }