EdgeCollider2D for the same points as LineRenderer has different position
I have trouble of understanding world space vs local space in my LineRenderer and EdgeCollider2D components.
I have a player GO with attached LineRenderer and EdgeCollider2D to it. I have a helper variable to store my moves as a following list:
private List<Vector3> _moveLinePoints;
Then in my update method I'm filling player's position as following:
_moveLinePoints.Add(playerPosition.position);
Then I set up my line renderer with those points and also my edge collider:
_lineRenderer.positionCount = _moveLinePoints.Count;
_lineRenderer.SetPositions(_moveLinePoints.ToArray());
var vector2Points = _moveLinePoints
.Select(point => new Vector2(point.x, point.y))
.ToList();
_edgeCollider.points = vector2Points.ToArray();
My line renderer has useWorldSpace set to true because if it's not it has some strange offset (so I assume that playerPosition.position
are world coordinates, right?)
When I run my game I see Liner Renderer with correct position and my collider with wrong position:
How can I change my EdgeCollider points to be world space related?
Your answer
Follow this Question
Related Questions
Why does localPosition only work when there is a parent object? 1 Answer
Don't understand parent vs child transform in world and localspace 1 Answer
converting local space vector into world space? 1 Answer
Multiple interior collision spaces/pocket collision dimensions. 1 Answer
Global direction (e.g. Vector3.forward, Vector3.right) from Mouse drag 0 Answers