Search Unity

Resolved Any way to make a line renderer have collision?

Discussion in 'Scripting' started by jlorenzi, Jun 15, 2022.

  1. jlorenzi

    jlorenzi

    Joined:
    May 2, 2021
    Posts:
    292
    I want to make a drawing game, from what I've seen using a line renderer seems like the best approach for this. But I want the drawings to interact with the world, not just visual. Is there a way to make a line renderer behave like an object?

    Just for some extra info, I don't need physics to apply to the line renderer. All I want is for the line to collide with things.
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    Collisions with other objects is part of physics. If you don't want it to be affected by gravity or move when other objects collide with it setup rigidbody appropriately as described in "Body Type: Static" section of https://docs.unity3d.com/Manual/class-Rigidbody2D.html . You can create polygon or edge collider vertices in similar way as you create vertices for line renderer.
     
    MelvMay likes this.