Draw TrailRender in parent object space?

Hi,

I have an object that orbiting around its parent object and the parent is orbiting around( or moving) other object like Moon goes around the Earth and Earth goes around Sun. And I would like to get the child(moon) have trail render in its parent space not world space so the child can have circular trail render around its parent.

Is there anyway I can do this?

Thank you,

I’d like to ask the same, because my project has a similar situation.

Sounds like you could use a LineRenderer and manually set its first point to the moon’s localPosition each frame, while bubbling up/down the rest of its points…

var lineRenderer : LineRenderer;
var lineLength : int = 3;
var updateSpeed : float = 0.5;

var points : Vector3[];

function Start() {
 lineRenderer = GetComponent(LineRenderer);
 lineRenderer.SetVertexCount ( lineLength );
 points = new Vector3[ lineLength ];
 for ( var ix : int = 0; ix < lineLength; ix++ ) {
  points[ix] = transform.localPosition;
 }
 InvokeRepeating( "UpdateTrail", 0, updateSpeed );
 
}

function Update() {
 points[0] = transform.localPosition;

 for ( var ix : int = 0; ix < lineLength; ix++ ) {
  lineRenderer.SetPosition( 0, points[0] + transform.parent.position );
 }
}

function UpdateTrail() {
 for ( var ix : int = 1; ix < lineLength; ix++ ) {
  points[ix] = points[ix-1];
 }
}

Something like that.

Thank you very much for your reply… I will give it a shot.