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$
4
  • $\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$ Oct 12, 2014 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$
    – ruckus
    Oct 12, 2014 at 2:48
  • $\begingroup$ Where would i post? $\endgroup$
    – ruckus
    Oct 12, 2014 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$ Oct 12, 2014 at 3:19

1 Answer 1

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$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .