Thursday 2 February 2012

Bug Fix : Tutorial 4 - Waypoints

As has been pointed out in the comments, in the fourth tutorial we added some code to check if the enemy has gotten close enough to the way point to move onto the next. This works well if the enemy is moving with a speed <= 1, however not so great if it moves with a speed of 2 for example.

To fix this we simply change :

if (DistanceToDestination < 1.0f)
{
    position = waypoints.Peek();
    waypoints.Dequeue();
}

to :

if (DistanceToDestination < speed)
{
    position = waypoints.Peek();
    waypoints.Dequeue();
}


Thanks for pointing this out Ryan! This was what I had intended to write but for some reason left the speed hard coded...