Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiple Rigidbody2D's and ----Collider2D's on one object

Discussion in '2D' started by Ekibyou, Aug 19, 2014.

  1. Ekibyou

    Ekibyou

    Joined:
    Feb 19, 2014
    Posts:
    10
    I am currently creating a game where you swing around weapons with physics.


    As I have been improving on weapon handling, I got a problem. Some weapons have a different center of gravity (which I can change, but not optimal in my case), so I need to create multiple rigidbodies and colliders for a single weapon. For instance, I can have a club like below.

    The top part of the weapon is of course a lot heavier. If I leave the center of gravity in the middle, the weapon simply does not handle nicely; a lot of force is lost while swinging because there's not enough weight at the end of the weapon.

    While researching, I found out I can do it with the 3D physics (fixed joints), but I'm using the 2D physics, so the option I had in mind was not possible anymore. How would I go about doing this?

    Thanks in advance!
     
  2. Melang

    Melang

    Joined:
    Mar 30, 2014
    Posts:
    166
    Tbh I don't know how to move the center of gravity, but you asked about multiple colliders on one object - this can be done by adding a child game object with a collider. You can then add a public property on your script and assign that child collider there for ease of use.
     
  3. Ekibyou

    Ekibyou

    Joined:
    Feb 19, 2014
    Posts:
    10
    Well then you have the collider, but not the physical properties: the rigid body. That's the thing I want since it controls the mass and such. If I put that in a child object, it'll simply fall to the ground and not stick to the parent. I can't use the Fixed Joint because it is only for 3D physics... See the problem I'm having?
     
  4. Melang

    Melang

    Joined:
    Mar 30, 2014
    Posts:
    166
  5. Ekibyou

    Ekibyou

    Joined:
    Feb 19, 2014
    Posts:
    10
    Mmm... A distance joint with a distance of 0 might work, I suppose.