Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Physics locking on the x axis for 2.5D game

Discussion in 'Physics for ECS' started by argibaltzi, Aug 13, 2020.

  1. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    193
    Hello

    I have been using some of the answers here to set the InverseInertia in PhysicsMass to 0 for x and y in order to achieve "one axis" physics.
    This has been working fine for the most part however it doesn't seem to work 100%. is this how its supposed to be? anything that can be done to achieve physics on 1 axis



    i have some debris that explode and most of them stay on the x axis but quite a few of them behave like there is no constraints

    so the desired behaviour needs to be movement on X and Y axis and rotation Z or all rotation axis. The most important is no Z translation....

    Thanks!!
     
    Last edited: Aug 13, 2020
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Setting the InverseInertia to zero on 2 axes stops internal solver collisions introducing a rotation on those axes but won't necessarily stop linear deltas or your own code from setting angular velocities.
    You could simply set the Z component of the translation on bodies to 0 each frame (and appropriate rotation and velocity resets/limits).
    Alternatively add a LimitDOF Joint to all your bodies. Check out the related sample scene or the forum discussion on this topic.