Rotating missile around target?

how do i get an object to point in the direction of another object while moving around, like a missile homing in on a target?

You will need the missile image to be facing to the right (not rotated in the editor, but the actual image you use for the sprite). Then use rotate towards position with a speed of 0 (i.e. immediately face that direction) :


1 Like

As MrMen says, you have to draw your image facing the right side. Maybe you could explain more about what you’re trying to do, because if the object is moving following a target, I think the best way to aim your object (let’s say a missile) is to make the angle of your missile the direction of movement. In other words, if you want your missile to follow a target and the missile is moving with forces, maybe you can use something like this:

1 Like

first of all, i just want to say thanks again to both of you for the advise, the flying path works perfectly now. but if it isn’t too much trouble i have one last question. so my player character turns into the missile object when a button is pressed, but when they turn back they’re stuck/tilted on the wrong axis(like the player object is now upsidedown when they turn back to normal), is there a way to reset the players rotation after turning back?

You have to take into account in the first instance that the angle modification is not being applied when it returns to normal (limit to only modifying the angle in this way when it is a missile); for example, using as a condition that it only applies this angle modification when the character is in the missile animation. On the other hand, take into account both the origin and center points of the objects and animations. Is any of these points that are causing problems?

1 Like

i understood the part about the origin and center points (i’ve edited a lot of them, so this might be where i should start revising) but you kinda lost me on applying the rotation modification to specific conditions (im still learning the ins and outs of condition system so might be using the wrong conditions?). Could i see an example of the conditions your talking about that would specify my rotation to just the animation?

I think it would be easier if you show how you have set it up. It is not the same if the character and the missile are the same object but with different animations than if they are different objects. However, if they are the same object but the animation changes when it transforms (which I assume is the way you’ve done it), you have to refer to the animation that corresponds to the missile in the conditions. For example, the missile animation is the animation number 1 (and 0 the character animation):

1 Like

unfortunately my code but its a bit messy and in need of cleaning, so it’d be pretty hard to explain. however you did give me the idea of just turning the to actions into seperate sprites and swapping between them when their action is triggered, despite me probably having to optimize it a bit later down the line it seemed to have fix all my problems atm. but nonetheless thank u for the help!