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...

4 comments:

  1. I've been following your tutorials, they've helped me a lot. =)

    Will be there any more tutorials?

    Thanks and good luck!

    ReplyDelete
  2. FireFly I need your help. I am having this really weird double-selling glitch/bug. When i sell a tower, it disappears, but still shoots at things. After I sell it, I am able to sell it again and get twice the money, and then the tower stops shooting and i can place another tower there.

    ReplyDelete
  3. Hey, I'm sure you're busy but I was wondering if I could get your help with something. I'm trying to use animated sprites for the enemies, but when they're drawn they don't move but they do their animation. Feel free to email me, I can reply with my source code.

    ReplyDelete
    Replies
    1. my email is bulletjr@hotmail.com btw.

      Delete