Reputation: 13
A few days ago I watched a video called "Coding Adventures: Solar System" which was made by Sebastian Lague. It inspired me to make my own simple simulation of the Solar System. Everything was fine until I needed to draw the orbit trajectory to set my Initial Velocity properly. I was searching and searching and didn't find anything. So here's my question. How can I draw an orbit trajectory in Unity?
Upvotes: 1
Views: 3256
Reputation: 26
The script he uses for the trajectory is in the Debug folder: https://github.com/SebLague/Solar-System/blob/Episode_01/Assets/Scripts/Debug/OrbitDebugDisplay.cs He basically create a new fake CelestialBody for each planet and calculate every position. He uses both DrawLine and LineRenderer.
Upvotes: 1
Reputation: 412
Use a LineRenderer
. It allows you to mark points along the object's trajectory given your ellipse equation, and it will create a corresponding line.
Upvotes: 1
Reputation: 21
I found this video: https://www.youtube.com/watch?v=mQKGRoV_jBc it is very well explained. It has a collection of videos to do exactly what you want to do.
Upvotes: 1