Homing missile

Blitz3D Forums/Blitz3D Programming/Homing missile

HNPhan(Posted 2003) [#1]
I used to be able to get my missile to home into a target, but somehow it doesnt work anymore, dunno what i changed that made it not work anymore but anyway, heres how i did it:

i create the missile with a pivot not parented to the missile, it is then repositioned every cycle to the missile.
the pivot then points to the target and i use:
turnentity missile,entitypitch#(pivot,1)/25,entityyaw#(pivot,1)/25,entityroll#(pivot,1)/25

and then move the missile along its Z axis. has anyone tried that method? i seem to have forgotten something


Sunteam Software(Posted 2003) [#2]
I think it's because your using the pivot's absolute rotation value to influence the turning of the missile. What you need to do is work out the difference between the two absolute angles of the pivot and missile, divide that by 25 and then turn your missile. Something like this:

piv_pitch#=entitypitch(pivot,1)
piv_yaw#=entityyaw(pivot,1)
piv_roll#=entityroll(pivot,1)
mis_pitch#=entitypitch(pivot,1)
mis_yaw#=entityyaw(pivot,1)
mis_roll#=entityroll(pivot,1)
TurnEntity missile,(piv_pitch-mis_pitch)/25,(piv_yaw-mis_yaw)/25,(piv_roll-mis_roll)/25


I haven't tested this obviously but you should get the idea.


mrtricks(Posted 2003) [#3]
The only problem you get with that is at certain points the missile will flip round suddenly when one value crosses between 360 and 0.

A more succint way of doing this which works very smoothly for me, is to have a pivot as a child of the rocket. Every frame, point the pivot at the target using PointEntity, then you have the exact yaw, pitch and roll differences. Then you can turn your rocket based on that.


HNPhan(Posted 2003) [#4]
thanks for your help, this was actually a double post :/
on the other thread, it was resolved using DeltaPitch and DeltaYaw, its much better IMO :D