- Home /
Drawing a moving objects trajectory
Hi,
I have searched high and low for an answer to my question but to now avail so here goes:
I have a project to create a solar system, that is planets rotating around a cetral sun. Nothing realistic mind you, just spheres moving around a point in random ellipses, no gravity or physics involved.
As the planet's trajectories are randomised at runtime I was hoping to draw their trajectories... Is there a simple way to do this? I have looked at gizmos, linedraw and trail functions but none of them have the functionality Im looking for:(
Any suggestions? Maybe im going about this the wrong way, Im really not very experienced at this.
Many thanks
cheers!
What functionality are you looking for? You haven't actually described what you want.
Answer by Tuti · Dec 01, 2010 at 06:08 PM
I would put a "fake" and invisible planet moving faster than the actual ones. Then you assign a "Trail Renderer" particle system. They would draw a path that you are looking for.
Not so much 'faster', but in front of the others. Not so sure about the performance issue though. Also, Necromancy.
Answer by Mike 12 · Dec 01, 2010 at 10:54 PM
TrailRenderer wouldn't do the trick for you? It'd be easier for people to help you if you told us what kind of functionality that you were looking for. Because, there are ways to go about drawing the trajectory of an object in Unity that you might like.
If you want the trajectory to be drawn after the object has passed that point, then you could just attach a TrailRenderer to our planet. However, if you want to draw the trajectory from the beginning, then I suggest that you store your trajectory in an array and implement your trajectory line as a LineRenderer object.
Answer by Bob5602 · Dec 01, 2010 at 02:34 PM
Do you need the trajectories completely, or just a trail after the spheres as they move? If its just the trail, I could suggest using some sort of particle emitter on the spheres to leave little specks as it moves, creating a trail with the traveled trajectory.
Answer by Rennat · Dec 01, 2010 at 05:59 PM
I might approach this problem by creating a ring texture with an additive particle shader, placing it on a plane and then aligning/scaling that plane to match the orbit of the planet. (Depending on the screen size of the orbit this may or may not look good)
Or you could create a circle using short LineRenderers
Or if you set a TrailRenderer's duration to the same period of time as a planet's "year" then set the trail not to fade out (full alpha in the colors) then it should simulate this after the first orbit.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085237im_/https://answers.unity.com/themes/thub/images/avi.jpg)