Find look at rotation not giving expected results

I’m trying to get an effect where upon the player ship enters within range of a planet and the player presses a button, the ship will rotate to align itself parallel to the planet and then orbit around it. Find look at rotation seemed to be exactly what I needed but when I set up my script and go to test, the results get all wonky.

305927-gif2.gif

The only thing happening in this situation is the rotation of the ship being set on tick and an impulse being added along the ships up vector so it flies in the direction it’s facing. What I expected to happen was the ship’s forward vector, i.e its right side, would face towards the planet, but that only happens some of the time. I’ve tried a bunch of things to fix this but haven’t had any success. Would anyone be able to help me figure out what exactly is happening?

If you want the bottom of the ship ( or forward vector, just saw the rest of your post ) always pointing at the planet, you need to connect all the pins. You’re getting weird results because you’re only using the Y pin.

Try all pins first, you’ll find ‘some part’ of the ship is always looking perfectly at the planet. Then it’s just a case of getting the right part of the ship to align.

EDIT2: Ah, but wait, I typed to soon. It’s a sprite.

Look at rotation is 3d, ( thinks… )

EDIT3: It’s because look at is not enough, you need to follow a path around the planet. Using look at to control the ship’s rotation, but you also have to figure out the math to orbit the planet…

Yes, I was afraid you were going to ask that. I was just trying to figure out a simple way. I did this with the standard twin stick shooter project ( which is kind of 2d ):

305941-spaceship.gif

I just put components around the planet. The spaceship just finds the nearest one and then moves into position ( with the compulsory ‘look at’ of course ).

Do you have any recommendation about how to best go about calculating a path? For the purposes of gameplay, I want the orbit to be just a circle around the planet that the player follows at the speed and distance they are at when they initiate the orbit.

No worries. If you find it useful, please come back and tick the answerm it will help others.

( keep getting logged out ). BP goes like this ( this is on tick in the space ship, the stuff off to the right is the standard twin stick BP ):

I’ll just tidy up the function and then post that:

It’s pretty inefficient at the moment because the function should be called once and it’s being called every tick, but…

Also, obviously, normally the ‘orbit’ components would be hidden.

1 Like

Thanks a bunch. I’ll look into this.

Thanks a ton for your help with this. This helped push me in the right direction and finally get unstuck.