Search code examples
unity-game-engineunityscript

[Unity]How to draw a Ring Line in 3D


I'd like to draw the trajectory of an object that is moving circularly, but I do not know how to do it. Could you tell me a good way?


Solution

  • I've not done a orbiting around something, but I am using Cos and Sin to generate static items around the object. If you use TrailRenderer with the use of MathF cos and sin to rotate around an object.

    var y = amplitude * MathF.cos(Time.timeSinceLevelLoaded * speed) + currentPosY
    var x = amplitude * MathF.sin(Time.timeSinceLevelLoaded * speed) + currentPosX
    

    I've not watched it, but "Board to bits" on youtube has a tutorial on the matter. of space orbiting for a planet playlist.

    Hope this is the right direction for you.