2D waypoints - any example code?
Blitz3D Forums/Blitz3D Beginners Area/2D waypoints - any example code?
| ||
Been writing some code to let my sprites find their way around a track on screen. At present I'm using a color-coded bitmap, but as an alternative I'd like to try and write a waypoint based AI. I plan to store say 32 waypoints in an array. I assume I'd take the first 3 points in the array and plot a smooth curve through them. After the sprite passes the 1st point, I'd load the 4th point in and plot a smooth curve through points 2, 3 & 4 - and so on all around the track. Is there any sample code kicking around ? |
| ||
I should add I already have waypoint code running but just uses SIN & COS to plot the angle to the next point What I want to do is plot a smooth curve through the next point instead. |
| ||
Have a look at this by "Ross C" - parts of it may be of use to you: http://www.blitzbasic.com/codearcs/codearcs.php?code=940 |
| ||
thanks for that |
| ||
i think all he's doing here is working out the angle in between each waypoint. the implication for me is I would need lots of waypoints to describe a bend in the track Maybe's I need to study some maths books to work out how to FIT a curve between several waypoints |