- Home /
LineRenderer Collision
Hi guys.
I am having a little problem with my line renderer collision detection.
I have 2 balls in sort of like an orbit, so a line renderer is drawn from ball A to ball B, so in other words, the line renderer moves as the balls move & what i want to happen is for everything that comes in contact with the line renderer to be destroyed.
It seems like the collision detection only works on point 0 if the line renderer, which is at the centre of ball 0.
How can i fix this, i want the whole line renderer to detect collision with items tagged "leaf".
RaycastHit2D hit = Physics2D.Raycast(lr.transform.position, transform.right);
for(int i = 0; i < points.Count; i++){
lr.SetPosition(i, points[i].position);
}
if(hit.collider != null && hit.collider.CompareTag("leaf")){
Destroy(hit.collider.gameObject);
Debug.Log("destroyed leaf ");
}
// lr is a public line renderer
Comment
Your answer
Follow this Question
Related Questions
Destroying objects in a set order 0 Answers
Quick question. 2 Answers
Why is OnTriggerExit2D called before OnTriggerEnter2D? 1 Answer