Hello again Unity community!
I’m trying to script an enemy rolling along the ground that occasionally hops up after two seconds. This means I want the enemy to continue moving left, but occasionally go up and down while still moving left. However, I cannot get the enemy to continue moving left while the hop occurs (meaning the enemy stops in its track when it moves up and down), and I think it has something to do with the yield Coroutine stopping the left movement.
Anyone have any ideas or leads how to work around this issue?
My current code is below.
function Start () {
while(true){
yield WaitForSeconds(3);
yield MoveObject.use.Translation(transform, Vector3.up * 3, 2, MoveType.Time);
yield MoveObject.use.Translation(transform, Vector3.down * 3, 2, MoveType.Time);
}
}
function Update () {
transform.Translate(Time.deltaTime * -3, 0, 0);
}