x


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!

more ▼

asked Dec 01, 2010 at 02:10 PM

Ddarz gravatar image

Ddarz
1 3 2 2

What functionality are you looking for? You haven't actually described what you want.

Dec 01, 2010 at 03:51 PM Eric5h5
(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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.

more ▼

answered Dec 01, 2010 at 10:54 PM

Mike 12 gravatar image

Mike 12
136 16 14 15

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 01, 2010 at 02:34 PM

Bob5602 gravatar image

Bob5602
603 39 31 46

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 01, 2010 at 05:59 PM

Rennat gravatar image

Rennat
784 19 15 27

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 01, 2010 at 06:08 PM

Tuti gravatar image

Tuti
405 1 3 9

Tuti answer would be the lightest performance one.

Sep 24, 2011 at 07:28 PM overunity3d

Not so much 'faster', but in front of the others. Not so sure about the performance issue though. Also, Necromancy.

Sep 25, 2011 at 02:08 PM syclamoth
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x188
x83
x23
x12
x3

asked: Dec 01, 2010 at 02:10 PM

Seen: 3221 times

Last Updated: Sep 25, 2011 at 02:08 PM