1
\$\begingroup\$

I’m trying to make the orbital paths visible for my solar system simulation game. I have most around with trail renderers and solid line sprite but not achieving the desired look I want. I’m hoping to get something where the path is alway present but darker directly behind where the planet currently is, and lighter and more transparent ahead of where it’s going. This effect is achieved in the game Worbital. worbital example here

If anyone could point me in the right direction how I can achieve this I would be much appreciated.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ When you say you are not achieving the desired look you want, do you mean you don’t like the way the line itself looks, (maybe whatever you tried before had visible aliasing for example,) or are you asking how to achieve the “lighter-ahead, darker behind” effect given a method of drawing lines? \$\endgroup\$
    – Ryan1729
    Sep 15, 2020 at 5:47
  • \$\begingroup\$ yeh i was trying to draw it with the built in trail renderer, which does look good but starts drawing when you play, so it wouldnt make my desired effect until the plants made a full revolution. What im looking for is a way to make it from the beginning of the planet cycles \$\endgroup\$
    – Jeremy
    Sep 15, 2020 at 20:06

2 Answers 2

1
\$\begingroup\$

Don't use a trail renderer, use its static cousin line renderer.

You can control the width of the line renderer using curves. So a linear falloff from 1.0 at the beginning to 0 at the end will give you a "tail" which looks similar to a trail renderer.

In order to create a circular line, you might want to generate the positions of the line procedurally.

Here is an untested code example.

float radius = 10f; // radius of circle in units
int num_points = 360;  // adjust based on desired tradeoff of performance vs. quality
var points = new Vector3[num_points];
for (var i = 0; i < num_points; i++) {
    var angle = (Mathf.PI * 2f) * ((float)i / num_points);
    points[i] = new Vector3(Mathf.Sin(angle) * radius, Mathf.Cos(angle) * radius, 0f);
}
lineRenderer.SetPoints(points);

I don't know how you built your scene, so I had to make a couple assumptions. Should the circle be in the wrong orientation (vertical instead of horizontal), change the order of arguments to new Vector3()). I don't know if your planets orbit clockwise or counter-clockwise, so if the trail is in the wrong direction, replace angle with -angle. Should it be off by 90°, switch Sin and Cos.

This code is also rather costly (both calculating the points and setting them), so you might want to do this only once in Start() and then just rotate the LineRenderer with the planet while it moves on its orbit.

\$\endgroup\$
0
\$\begingroup\$

It really depends on your use case.

But if your orbits are not 1000000 light years long you can use a semi-transparent mesh (torus from Blender, or ProBuilder, just find the setting for the thickness ) for your lighter colored path, and a particle system or VFX for your darker stuff, that trails the ship.
You might have to smoothen out some edges if it looks too blocky. Might not be super optimized but can be set up realatively quickly.

Or you can divide up your path torus and call something on OnTriggerEnter() and do some color changes to that part of the mesh...

Hope it helps!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .