tracing rocket movement

Blitz3D Forums/Blitz3D Programming/tracing rocket movement

ryan scott(Posted 2005) [#1]
i am looking to make a rocket that can turn towards and chase my player.

i have code that does that - it turns towards him a little using alignentity and moves forward.

the deal is that i want the rocket to slide sideways as it is turning, instead of always going forward - it needs to have sideways momentum. if you turn the rocket 90 degrees it shouldn't immediately start moving 90 degrees to its initial vector, it would still slide in the original direction for a bit. like your ship in asteroids.

is there any code for simulating this? i need it only in 2d, essentially because my playfield is flat.

thanks for any help!


ryan scott(Posted 2005) [#2]
hmm what if i made the rocket like this:

parent pivot, child rocket

turn rocket towards player more than turning pivot to player.

I think one the keys to 3d programming is judicious use of Pivots(?)


Rob Farley(Posted 2005) [#3]
I do this sort of thing with physics pivots...

OK... Create a physics pivot.

Place it at 0,0,0
Point the pivot in the direction of thrust, and move it forward however much thrust you are using (1 for the sake of argument)

Then apply a bit of dampening to it, ie, take the x,y,z and x co-ords and multiply each one by .9 or whatever, then reposition your pivot.

Now, translate you actual rocket the x,y and z positions of your pivot.

Now if you change the direction of your rocket, change the orientation of the pivot the same. Then your physics pivot will apply the force in the new direction. However, the exisiting forces will still be applied but be dampening each update.

I feel a bit of code coming on to demostrate this...


Rob Farley(Posted 2005) [#4]



ryan scott(Posted 2005) [#5]
Thanks Rob!

Question: why did you not make the rocket a child of the physics pivot? i was thinking you could turn the pivot 20% towards your target, and turn the rocket another 20% more. rocket faces target more than pivot, but pivot does the movement, so the rocket appears to slide into its turn. this has other benefits for me because i am going to have more than just rockets but a spinning model on a straight moving pivot for example. easy code - move pivot, spin model, it'll look cool.

More importantly: the question about child/parent is because I just turned my rockets into pivot parented to model instead of just model, and i lost all my collision detection. is there something i don't understand about child/parent that collisions on the child aren't detected?

when i make a new bullet. b\piv is new bullet, w\piv is 'weapon' which stores the original.

b\piv = CopyEntity(w\piv)
b\model = CopyEntity(w\model) ; child of piv
EntityType(b\Model,T_BULLET)


all my movement routines use b\piv. bullets behave same as when i was moving just the model itself.

collision routines still use b\model, which makes sense to me. but the bullets no longer detect collisions :(

am i missing something everyone else knows?


ryan scott(Posted 2005) [#6]
ye gods, it appears that your collisions need to be on the parent? i changed collisions to the piv instead of the child model and it appears to work again.