Orbit Mechanics

So I’m trying to create a pawn that moves in a fixed orbit around a ‘planet’. What I have so far is working somewhat, but after moving forward a bit and then stopping, the pawn ‘falls’ back to the correct orbit distance. How can I make this where the pawn always stays at the fixed orbiting distance?

I think you should implement your own movement behavior and not just use the default pawns movement implementation.

your pawn can have the main mesh ‘offset’ in one axis from the main root (defaulsSceneRoot?) lets say X axis…if yor mesh has the relative transform as 500,0,0 then it means its 500 units distance from pawn center.

you can then attach your pawn to the planet, put relative pawn actor location to 0,0,0 and add local rotation of your pawn…it should rotate around the planet.

The way I would do it is to store a vector variable that’s your movement direction.

First, get your Input Axis Value * Fwd Vector and save it as your movement direction.

Inverse transform that so you get local coordinates, then zero out all movement input in whatever direction you’re using as the vector that points towards the central body.

You can also zero out one of the perpendicular axes if you only want the body to orbit in a fixed line.

Transform that back to global coordinates and plug that into your world direction. Let me know if it works.

I tried something slightly similar, but a simplified version. I added a rotate vector node, pitching the y down slightly, to the forward vector. That seems to have worked for now, but open to options that might be less expensive. Using this logic for the player currently, but all obstacles/enemies/projectiles will need to use the same logic, so a simplified ‘maintain this distance’ solution would be ideal.

They’re just basic vector operations, it shouldn’t be prohibitively expensive or anything. I honestly wouldn’t sweat it.

Chances are any performance issues will come from the GPU and if you really want to optimize your game logic, consider switching to C++.

I was trying to make the pawn ‘fly’ and have that work like I wanted, but the more I thought about using rotation for movement the better it sounded. Tried it out and not only is the logic pretty simple, but created the exact movement I was looking for. Thanks!