I am having an issue in unity where my object will do a translation and then nothing else, I want a sequence of translations and rotations to occur but it only does the first translation in the code and wont stop, I tried using a separate function to execute the translation instead of the Update function but this didn't work either, please help.
void Update ()
{
if (enemyHit == false)
{
//enemy moving
transform.LookAt(TTarget);
}
else if (enemyHit == true)
{
Debug.Log (enemyHit);
Evade();
}
}
IEnumerator Wait(float duration)
{
yield return new WaitForSeconds(duration);
}
void Evade()
{
transform.Translate(Vector3.back * Time.deltaTime * movementSpeed);
Wait(2);
transform.Rotate(0,90,0);
}
enemyHit, you may be callingtransform.LookAtonce per frame, which would tend to overwrite any other rotations that you're trying to do.