public void Move()
{
Debug.Log(“Will Step”);
for(int k = 0; k < distance; k++)
{
Debug.Log("Stepping");
Debug.Log(k);
prey.transform.position = Vector3.MoveTowards(prey.transform.position, aiCor, step);
}
Debug.Log("Stepping Done");
}
when i play this script it just completly skips the for loop
the debug menu just says: Will step, Steeping Done
and nothing well step
please help!!
This means the for loop condition (k < distance) wasn’t fulfilled.
So, the only explanation is that the “distance” variable has a negative value or zero.
Hi @Bubble0907!
Did you just delete your old thread to post this new one?!?! I made an answer for you :P.
- my main question for you is, how are you calling “public void Move()”? Are you using an event? or is it being called on update or start? depending how it is called will vary how often it is called.
- Second question, how are you defining “distance” how is this number increasing in value? as K needs to be less than distance, and will not run until distance is greater. This appears to be a logic error
Thanks, Shanks37