Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Custom physics in Unity

Discussion in 'Physics' started by FabioZocklabs, Nov 29, 2020.

  1. FabioZocklabs


    Jul 11, 2019
    Physics in Unity work pretty realistic.
    When something touching a ground is accelerated, it does not move until the force is strong enough.
    But this realistic physics is not good for most scenarios.

    The main problem I have is moving a character along the ground.
    The character is basically a rigidbody, who gets accelerated in the input direction, until ne reaches some maximal speed.
    So when just using a simple physics material, the character does not move until ne reaches some speed, and then starts moving at a pretty high speed. The best solution I found is using a frictionless physics material for the character, and faking some slowdown by touching the ground myself.

    I think a better solution would be some linear friction, which just slowly deaccelerates the character, but never stops nem.

    The exact way, how I'd want it to work, is by applying a force at the contact point to both objects. The force depends on some friction factor and the velocity difference at the contact points.

    For example, when standing on a slope, you would always slide down, at least slightly, no matter how high the friction is, except for the maximum friction.

    I thought, one of the frictions works that way, so setting one of the frictions to zero, the other one a bit below 1, and the combine to multiply would work, but it doesn't.
    If just one of the frictions is 0.8 (which means, the actual friction should just be 0.64), the character does not slide down.

    Is there a good solution for physics to work in the way, I'd like them to?

    I guess, when setting friction of all materials to zero, I could do something useful in `OnCollisionStay`. I might just try it.