Search Unity

Is there a way to make two rigidbody2D's act like one is parented to the other?

Discussion in 'Physics' started by Afropenguinn, May 10, 2018.

  1. Afropenguinn

    Afropenguinn

    Joined:
    May 15, 2013
    Posts:
    305
    So basically, I want one rigidbody to rotate and move with respect to the other, but still be free to move around itself. My use case is that I want a space ship that you can enter and travel in from a top down perspective. While outside the ship, you'll be in a dragless environment (being top down, the gravity is essentially determined by drag), but while in the ship it should feel like the ship is stationary, even while it's in motion. I could accomplish this by making the ship's interior a separate "room" that's stationary, but I wanted to at least attempt a seamless transition.

    So far I've tried various joints, having the most luck with the friction joint, with the downside being that the rigidbody in the ship now affects the ship's rigidbody. I'm pretty new to using the physics engine, so any help would be much appreciated!
     
  2. knobblez

    knobblez

    Joined:
    Nov 26, 2017
    Posts:
    223
    it sounds like you have to do this though script mostly.

    if one GO moves out of the radius of the leading GO it will receive force(like a nudge) towards the center of the leading GO.
    i dont think you could accomplish the flowy effect by parenting it because they are locked together.

    is this world super huge? if youre worried about gravity drag changes it must be a large ship inside a very large map...sounds like it anyway.

    you might want to reduce drag onColliderEnter(entering the spaceship)
    and add drag onColliderExit(exiting the spaceship). that should give you a nice effect if you adjust the drag correctly.

    im a noob