Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question render a rope for visual effect only

Discussion in 'Physics' started by hhheidi, Dec 1, 2022.

  1. hhheidi

    hhheidi

    Joined:
    Sep 3, 2022
    Posts:
    2
    Hi everyone, I was wondering how to render a line that looks like a rope but doesn't affect any rigidbodies or move any objects. Because this is only for visual effect I'm wondering if I can avoid using much complicated physics.

    For more information, I'm working in 2D and the rope is supposed to resemble a leash.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,701
    Is this a rendering question or a physics question? It's in the physics forum but your whole post seems to be discussing rendering which would be a General Graphics question.

    Why would rendering affect physics? Why would rendering "move any objects"? The question really doesn't make sense.
     
    arkano22 likes this.
  3. hhheidi

    hhheidi

    Joined:
    Sep 3, 2022
    Posts:
    2
    Because the line/rope should look like it has physics...? It's a line that should be affected by gravity (or some imitation of it). I wasn't sure if I should use a LineRenderer with "gravity" coded in, or if I should use some physics component and, I don't know, set the mass to 0 so it can't affect any other rigidbodies in the scene.

    If this is the wrong category can I repost my question in General Graphics? Should I delete this topic?
     
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    2,036
    So you want a rope that doesn’t have physics but looks like it has physics? I don’t think this makes any sense…

    if you want the rope to move realistically, it must “have physics” of some sort: either the built-in physics, or a custom solution you implement yourself. If you don’t want it to collide with other objects, just place it in a layer that is set to not collide with anything. (Btw, mass doesn’t have anything to do with collision detection, it has to do with collision response: that is, it won’t prevent or cause objects to collide, it controls how objects react once they have already collided)

    Ways of doing this: create multiple rigidbodies and attach them to each other using joints, then you can render them using a LineRenderer. This is by far the simplest method, and the one I would advise to use if you’re starting out since it only uses built-in stuff and the amount of coding required is minimal.

    Or, use an articulated body chain (only doable for 3D physics), or implement your own verlet/position-based simulation if you want absolute control over it. If you want to go this route, there’s myriads of tutorials about this all over the internet, one example:
     
    Last edited: Dec 8, 2022