Thank you! I will try this out after some much needed sleep.
Just a thought before bed. Would the best method/algorithm in this situation be:
- Find out how much I have overshot the desination node
- Move the object back to the destination node.
- Find the direction to move in for the next node
- Move in the new direction with the amount the object overshot the last node
- If the object overshoots the next node repeat all of the above, if not carry on moving normally.
Or can you suggest a better method than this?
Thanks for your help.
Main Topics
Browse All Topics





by: h2g2guyPosted on 2009-09-29 at 13:42:49ID: 25453246
What about this:
Before moving your object, find the displacement between the object and the next node as a Vector2 (or 3, depending on the game). Then, immediately after moving the object, find the displacement again. Normalize both vectors. If they point in opposite directions, then you know that you have passed through the node.
Keep in mind: if you use the code I typed in below, rounding errors might make the 'if' statement always return false. If this happens, let me know.
Select allOpen in new window