|
Hey! So, I'm implementing heat-seeking missiles in a platformer game. Basically, I'm attempting to code a kind of inertial movement where the missile goes after an object (in this case, a helicopter) in the most efficient way possible. But that route will be limited by its turning radius--it won't be able to turn fast enough if the helicopter "dodges" it by moving out of the way. In any case, my strategy is to constantly adjust the angle towards the helicopter, and then just push the copter in the direction of a vector I'm constantly changing based on that rotation. I'm having trouble with the second part of that process. It seems to be doing something right, at times--because the missile generally will go in the direction of the helicopter. Any idea what I'm doing wrong, here? Let's assume, for the purposes of sanity, that the missile always starts at angle 0.
(comments are locked)
|
|
The logic in MoveForward() seems too complex to me. Would it not be much easier to keep a direction vector which you rotate with the missile? When moving forward, you just add it to the missile position. That would be only one line of code for the missile movement. Ah, good plan, let me try that...
Apr 20 '12 at 06:53 AM
Catlard
Hmm...I know what you mean, but how do I determine what the vector will be adjusted by?
Apr 20 '12 at 07:11 AM
Catlard
Ok, so I've updated my code based on what I think you're saying I should do...but it still appears to be brokentown. Any idea what I'm doing wrong?
Apr 20 '12 at 07:35 AM
Catlard
Is it the same wrong behaviour as before? Make sure that your direction vector points in the same direction as the missile. Also, if you have any physics enabled, it will not work this way, because the physics will conflict with your manual transformations. If it still does not work, you can post your current code.
Apr 20 '12 at 08:13 AM
senad
Hey, Senad, thanks for responding! No, it's not the same incorrect behaviour. Now it seems to make the same motion every time, regardless of how I modify the code. It sort of rotates around the point it's supposed to head towards... In any case, I've reposted the newer code over the older code in the original post...what do you think, now? Also, no rigidbody on the missile, so no worries about that.
Apr 20 '12 at 12:17 PM
Catlard
(comments are locked)
|
