I’ve been playing around trying to get a player controlled pawn/mesh to rotate around a pivot point in world space. An example of the effect i’m after would be a planet orbiting a sun. The difference is I want the player to be able to control the top and min. speed, acceleration, deceleration, & angle of orbit around the sun, etc. by using the keyboard or a game pad.
I’ve added the rotating movement component to some meshes in some of the starter templates and can get those objects to rotate continuously around a specified pivot when I preview in the editor. I even understand the speed direction adjustment using the yaw and pitch. The problem I am having is hooking this up to a player character so that player movement is around a specified pivot. I guess I need some ideas and guidance for implementation.
Can I use spring arm to constrain player movement a set distance from a central point?
or
Adjust the pivot on the mesh, but offset the pivot to force the object to rotate in local space but appear to rotate offset in world space?
or
Continue to use the rotating movement component that allows pivot point specification?
Easiest way is to move everything around player. Movement is relative.
Calculate all planet positions and rotatios store this all in arrays just like it all is done around sun.
Then move everything exactly opposite to vector from star to focused planet (ie earth or such.
Here is mine system, I do not use Kepler rules here, do not need them for arcade game.
Planet O - array with current planet positions
Planet O Delta - orbiting speeds of planets
Planet R - array with current rotations
Planet R Delta - rotation (or spin) speed of planets
Planet Pits - array with well pitch
Focused Planet Index - where earth is or planet with player.
This stuff is quite fun to play, you can simulate nice effects like conjunction etc.
To get player on planet orbit, best (and only one that does not give me headache) way is to use physics constraint
You need root, constrain and player pawn.
Hook one end of constraint to root other end to player, restrict constraint to angular only, limit all linear.
Then turn off gravity for pawn and set it to physics actor.
To move pawn you use thrusters, do not add impulse or change velocity it has bad effects on physics.
So add one thruster for forward/backward, and 2 for rotating.
Ps. I tried multiple times with add force to simulate orbital movement, and it works, but works too well. Result i got was real orbits, that are very hard to calculate starting parameters and forces. Also inaccuracy in calculations adds some drift to them.