3
$\begingroup$

How do I get my projectiles to follow my cursor until they pass it. I'm looking for an effect like homing missiles, but when they reach the corsors position, I want them to continue on their current trajectory.

My current situation is that they reach my cursor and then fly around it like an angry swarm of bees. They follow it everywhere rather than going past. Here is my code for my tracker, don't think its the problem though. I copied it out of a tutorial, so I wouldn't know if it has issues.

from bge import logic

def main():
    scene = logic.getCurrentScene()
    cont = logic.getCurrentController()

    mouse_over = cont.sensors["Mouse_over"]

    if mouse_over.positive:
        tracker = scene.objects["Tracker"]
        tracker.worldPosition = mouse_over.hitPosition

Also download my file here:

http://www.pasteall.org/blend/32080

$\endgroup$
  • $\begingroup$ When you say "cursor", are you referring to the actual mouse cursor in 2D screen space, or a 3D coordinate in game space, derived from mouse cursor position? Also, can you post a simplified .blend that demonstrates your "current situation"? $\endgroup$ – Goran Milovanovic Oct 12 '14 at 1:34
  • $\begingroup$ Game-Play location of mouse data. here is my code. from bge import logic def main(): scene = logic.getCurrentScene() cont = logic.getCurrentController() mouse_over = cont.sensors["Mouse_over"] if mouse_over.positive: tracker = scene.objects["Tracker"] tracker.worldPosition = mouse_over.hitPosition $\endgroup$ – Scalia Oct 12 '14 at 2:48
  • $\begingroup$ Where would i post? $\endgroup$ – Scalia Oct 12 '14 at 2:49
  • 1
    $\begingroup$ You should edit your question to include requested information (such as code or links to relevant files) - Don't just dump that stuff into comments. You can use pasteall.org/blend to upload your file, and then you can edit your question to include the link. $\endgroup$ – Goran Milovanovic Oct 12 '14 at 3:19
2
$\begingroup$

You can simply program the projectile to stop tracking once it collides with the tracker. An easy way to do that is to have a collision sensor on the projectile trigger a state actuator on collision, which will transition into a state where the track-to actuator is not included.

.blend: http://www.pasteall.org/blend/32088

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.