Creating a path for objects to follow

BlitzMax Forums/BlitzMax Beginners Area/Creating a path for objects to follow

Matt McFarland(Posted 2005) [#1]
How do you create a destined path for an object to follow?

If I were to draw by freehand a path, how would I get an object to follow that exact path?

Seeing as how I can think of many ways it could be done, what do you think would be most efficient?


Ash_UK(Posted 2005) [#2]
Hmm, plotting your points and getting your object to move from Point A to Point B etc. Obviously, the more points you have, the smoother your path will be. You will probably be better off using types to track each point of your path :)


Ash_UK(Posted 2005) [#3]
Hmm, plotting your points and getting your object to move from Point A to Point B etc. Obviously, the more points you have, the smoother your path will be. You will probably be better off using types to track each point of your path :)


Ash_UK(Posted 2005) [#4]
Sorry, i must have hit the post button twice ^_^


Matt McFarland(Posted 2005) [#5]
Point Plotting! Nice.. So I can code the plots and how they affect the ship when it reaches the plot. As of now I can't think of how to do bezier curves or anything.. Any suggestions?


Ash_UK(Posted 2005) [#6]
I think bezier curves may have something to do with using sin and cos but yes, you can control what happens when your object reaches a certain point on your path by returning an id of that particular point.


Barnabius(Posted 2005) [#7]
There's plenty of code in the archives showing how to work with Bezier curves or splines as they are also called. They are very easy to use and give excellent (i.e. natural) results for paths. And... you don't need sin and cos functions in order to work with splines...

Barney


Matt McFarland(Posted 2005) [#8]
so the keyword I need to search for is splines.. the word we call splines.


TomToad(Posted 2005) [#9]
Here's a function for plotting bezier curves. cp0-cp3 are your control points and t is a value from 0 to 1. The idea is to decide how many steps will be needed (the more steps, the smoother the line) then call BezierPoint to get the x-y point at that step.

Here is an example program using it.

Just use the arrow keys and KLO, to move the control points around