Hey, we're trying to make homing bullets. We tried calculating the angle between the bullet and the player and using orxObject_SetAngularVelocity on the bullets, but they aren't changing course. Is there something else we have to do?
If not, what are we doing wrong?
Do we actually have to use vector normalization, or is there a way to do this with angular velocity?
Comments
my current code does use normalization:
Doubtless there's a better way, but maybe follow the rules I do: "1: Make it work. 2: Make it good. 3: (If needed!) Make it fast."
Till I saw, Grey's solution, that is!
I still don't understand why normalization is really concerned because you could have had any norm on your force vector, but I'll put all that on sleep deprivation.
As for your first question, sonicbhoc, setting the angular velocity will impact the rotation of your object over time, but its speed will remain unchanged. So that won't do much in term of actual homing, just make your bullet face your target at best.
You might want to have a look at Craig Raynolds' page on steering behaviors.
It has been an inspiration for many of us for basic steering needs, and it's definitely a must read. Especially the seek & flee one. You can also download his OpenSteer for either direct use or learning purposes.
That being said, if you look at MushroomStew/src/Missile.inl (the Missile::Update() method), I've implemented a very basic homing missile code there that I use in the game.
Some people use them for this kind of tasks though they are known to be a bit tricky to tweak.
If it were me, I wouldn't go down that road for your use case. Just thought I'd mention it for the sake of learning though.