While it's easy for me to get a object circle around another and move toward it, i've got a few problems I couldn't find a solution to, yet.
Ill go here as follows: I) description of scenario II) problems I currently have
I) Description: My setup consists of multiple things:
1) I have a solar system - basically some planets rotating around the sun in a fixed circular motion with the sun itself unmoving. This one works fine - I currently do it with rotateAround in Unity, but I read into force related methods and I think I'm able to get it designed with forces if needed.
2) Space ships. These ships are either circling around a planet (kind of "i'm stationed here") or moving toward another planet (to station them somewhere else) The movement towards a planet as well as the circling around the planet for itself is easy as far as im concerned.. just some move-toward-point stuff or rotateAround point again. I could those 2 implemented with forces too.
II) the problems I have.
1) I can't get my head around a smooth transition from flying toward a planet into the rotation. My first idea was to use some kind of states for the ships "CIRCLING" and "FLYING" and change the state as soon as the desired orbit height is reached. (btw: I use a 3d environment but for the gamelogic I only require the motion to happen on 2d x-z axis only, if this is important to you). The problem with this is, that it's kind of a 90° turn and really looks bad.
2) the next thing i had was to just add another "Transition" state, when I get close enough, which will handle the smooth movement into the circular motion, but I don't know how to do it.
3) Do I have to care for anything else because the target I want to rotate around is moving itself? (so it doesn't look like they speed up when moving around the planet in same direction of the planets movement, while seeming extra slow when moving against planets movement)? (I ask this, because currently I only work with static planets to get the ships movement correct)
So basically my question is: How can I implement this transition? (I don't care if it is a statebased approach with directly applied position changes (with relation to time for constant speed) or if I have to use rigidbodies and forces or if you come up with something else.)
and as an addition: I also need the ships to avoid planets when travelling somewhere - so I was thinking about using the steering behaviour for collision avoidance, which in my understanding would work well with a force based approach, but I didn't completely wrap my head around that yet. (I don't want an answer to this part here, but wanted to provide you with a more complete specification of problems, which has to be possible to mix into the approach without hacking something together badly ;)).
thanks for any help, advice, links to useful resources :) kind regards