Search Unity

Best way to handle collision

Discussion in 'Physics for ECS' started by Eldirfar, Dec 28, 2019.

  1. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    65
    What would be the best way to force ship "stay" on water after collision? I would like that collision stop ship from moving through. I don't want to apply any velocity.

    https://imgur.com/a/3ncFNEX
     
  2. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    65
    For now I just set dampings and prevented rotation by setting physicsMass.InverseInertia to 0 and have system that in update set translation y to 0.

    upload_2019-12-29_12-59-46.png
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    What's wrong with setting monetarily velocity to 0?
     
  4. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    65
    I can but still i need to freez rotation and set transition y to some value
     
  5. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    You can change the response to any collision between any colliding pair. I recommend checking out the '5. Modify > ModifyContactJacobians' demo in the UnityPhysicsSamples project, specifically the Infinite Inertia cube. Penetration depth and Restitution is also a factor. Zero restitution on a body should lead to no bouncing, and a high interpenetration depth (especially when penetrating a static object) can produce a high recovery velocity.
     
  6. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    65
    Thanks, I will check the demo when I will back to this project.