Object Velocity
Blitz3D Forums/Blitz3D Programming/Object Velocity
| ||
Hi folks, What is the best method for determining an objects velocity accurately in 3D? |
| ||
Vipthreer, you've really got to use more words than that for decent help. The easy way is to record the last position of an entity the after an entity has moved take the new position from the last position. Blitz has many ways to make this easier. Simply use a pivot for the last position, ie positionentity lastpos,entityx(entity),entityy(entity),entityz(entity) then after the entity has moved entitydistance(entity,lastpos) will tell you the speed, then if you pointentity lastpos,entity then you'll get the direction. |
| ||
Velocity = delta displacement divided by time. v=d.s/t Speed can be worked out as above, using a delta-time variable to check the time change. i.e. |
| ||
I didn't think I would need to explain in more detail than that, sorry Mr Farley :) I was doing something similar, but it wasn't accurate enough. Never thought of using EntityDistance(). Anyway, that's exactly what I needed, thanks both. |
| ||
Entity distance uses pythagoras... so whatever you were doing, if not that, was simply wrong :P. |
| ||
Careful with those revelations, I nearly ran into the street and screamed 'Eureka!' :P |