Hi all.
I’m trying to make my ground for my game move for 1 minute then get set to inactive but when I get to my second Corrutine it just stops
This is what I’ve so far done:
using UnityEngine;
using System.Collections;
public class GroundMovement : MonoBehaviour {
private int groundCountdown;
private int groundMovementCountDown;
private float movementAmount;
// Use this for initialization
void Start () {
movementAmount = -0.1385f;
groundCountdown = 60;
groundMovementCountDown = 100;
StartCoroutine(BeginningMovement());
}
public IEnumerator BeginningMovement()
{
transform.Translate(new Vector3(movementAmount, 0.0f, 0.0f));
yield return new WaitForSeconds(0.001f);
groundMovementCountDown = groundMovementCountDown - 1;
if (groundMovementCountDown == 0)
{
groundCountdown = groundCountdown - 1;
transform.position = new Vector3(13.85f, -4.42f, 0.0f);
groundMovementCountDown = 200;
StartCoroutine(Movement());
} else
{
StartCoroutine(BeginningMovement());
}
}
public IEnumerator Movement () {
transform.Translate(new Vector3(movementAmount, 0.0f, 0.0f));
yield return new WaitForSeconds(0.001f);
groundMovementCountDown = groundMovementCountDown - 1;
if (groundMovementCountDown == 0)
{
groundCountdown = groundCountdown - 1;
transform.position = new Vector3(13.85f, -4.42f, 0.0f);
} else
{
groundMovementCountDown = 200;
transform.position = new Vector3(13.85f, -4.42f, 0.0f);
StartCoroutine(Movement());
} if (groundCountdown == 0)
{
gameObject.SetActive(false);
}
}
}
Any suggestions would be greatly appreciated.
Thanks in advance