- Home /
Set LineRenderer position at the centre of the parent after instantiate it
I'm trying to set the LineRenderer position in the centre of the parent but it's set in the wrong position
it's should be in this position
Here is the code that I tried
Vector3 SumPointsVectors = new Vector3(0f, 0f, 0f);
// filledRenderer point int Line rendere
foreach (var child in filledRenderer)
{
SumPointsVectors += child;
}
Vector3 Center = SumPointsVectors / filledRenderer.Length;
_lineRenderer.transform.position = Center;
Answer by virgilcwyile · Sep 08, 2020 at 01:39 PM
Where exactly is it setting right now? Please give a screenshot of that.
Edit:
After careful observation, here is what you can do. The linerenderer game object when you select is showing you the center point right? So you can create a GameObject and place it in that centre point, then Make the LineRenderer a child of that GameObject. Then set this GameObject child of your Cylinder Parent. After doing that, you can reset the GameObject's position to Vector3.Zero.
Alternate Solution: Another solution would be to create a Custom Mesh from your Points and then set the pivot.
Your answer
![](https://koobas.hobune.stream/wayback/20220613010813im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
LineRenderer (strange bug) 1 Answer
Camera rotation around player while following. 6 Answers
Line render from an object to a click 0 Answers
Add Icon and Distance (for LineRenderer) like google map 1 Answer
Line renderer length 1 Answer