Uniform trails regardless of speed.

BlitzPlus Forums/BlitzPlus Programming/Uniform trails regardless of speed.

Geehawk(Posted 2006) [#1]
Okay. I hate to admit it but this has me beat.

I have an object which follows an on screen path (which is always changing) autonomously. Behind this I wish to "tow" objects.

I have tried creating extra instances of the main type which, by their nature, follow the path too, but if I want the whole "train" to speed up then due to, I'm guessing, rounding errors etc. the following sprites tend to get closer or further away from the main sprite over time.
There is also the added overhead of having each sprite work out its own path.

I have also tried saving a list of the points that the main sprite passes through and using these to provide the data to position the trailing sprites. Again thats fine until a change of speed is induced, when you get the ripple effect as the saved points get further aparts and so the trailing objects get further away from the leader.

What should I be doing to make the following sprites keep pace with the leader as though they are being towed.

I'm sure I'm overlooking some obvious method.

Graham


Grey Alien(Posted 2006) [#2]
Can't you use the lead object and then calculate back a set amount from it along the path and draw the next sprite there? Also I don't get why you are getting rounding errors that result in a difference from the sprites to the main one, maybe you need to examine that code again.


Geehawk(Posted 2006) [#3]
Okay. It was not rounding errors, it was a result of all sprites being speeded (sped?) up at the same time. Those on curves would than take a slightly different route to the ones that passed that point at a slower speed, and hence could creep slightly closer or further away.

I have now added a distance from the previous sprite check which alters the individuals speed to allow it to catch up or drop back as necessary.

BTW Grey, thanks for the generous release of your CommonCode etc... finding lots of useful stuff in there :-)


Grey Alien(Posted 2006) [#4]
Glad you've solved it! and you're welcome re: my code :-) If you find anything useful, do me a favour and go and check out a few google ads on www.greyaliengames.com, thanks ;-)