Get LineRenderer positions or perform a transformation to an array of Vector3s
I want to create an elliptical ring where a planet will orbit on around a star. I have got a LineRenderer creating these rings but because I have translated the GameObject to have the star on the foci of the ellipse and i have rotated it to give it an inclination the coordinates are still where they were in the same place in relation to itself but they are completely different in relation to world space. I need to get the coordinates of this to get a planet orbiting. I thought I could use matrices to transform the array of Vector3's as if it were a mesh but don't know how to go about doing this. If i could translate and rotate the Vector3 array i can do what i did to the game object to find the right coordinates.
Read it twice, but I'm not quite clear what you are looking for: Perhaps InverseTransformPoint, or https://docs.unity3d.com/ScriptReference/Transform.InverseTransformVector.html?
Yea sorry I didn't explain it well. Ok so what I've done so far is create an array of Vector3's and then put that array into a LineRenderer. I have then manipulated the GameObject that the LineRenderer is attached to like rotate etc. After I have done these transformations to the GameObject the points in that LineRenderer are in different locations in relation to world space. I need to get these new positions but I cant get them out of the LineRenderer. Hope that helps
Answer by Glurth · Sep 11, 2016 at 02:46 PM
So you have a set of model-space points, that are passed through an object's Transform. You want to get the final world-space coordinate of these points. To do this simply pass those model-space coordinates, to the object's Transform's TransformPointFunction
eg
worldPoint[i] = object.transform.TransformPoint( modeSpaceLinePoint[i]);
https://docs.unity3d.com/ScriptReference/Transform.TransformPoint.html
Your answer
Follow this Question
Related Questions
Help with raycast for for wall detection 1 Answer
How to rotate the player towards a Vector2? 1 Answer
I want to make a script that causes the directional light to stop at 180 degrees. 0 Answers
Problem getting Vector3.Slerp to rotate in the correct direction in specific situation 0 Answers
Searching a function to get the rotation of one Vector3 in relation to another 1 Answer