Search Unity

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

Question Prevent vehicle and spherecast suspension from being so bouncy?

Discussion in 'Physics' started by YaBoyShredderson, Nov 15, 2023.

  1. YaBoyShredderson

    YaBoyShredderson

    Joined:
    Jul 5, 2023
    Posts:
    4
    I have spent a lot of time and effort making my own wheel collider using the sphere cast and so far it works very well. I do have some problems though. driving at any speed, even very low speeds (albeit its worse the fast you go) and hitting even a small bump launches the vehicle into the air. I am not sure what exactly is causing it, there are probable several reasons. My first thought is the way i calculate the velocity of the suspension for damping. I do "float suspensionVelocity = (_hit.distance - _previousHitDistance) / Time.fixedDeltaTime;". This isn't the same as the tutorial I used to assist me (the very very valet one I'm pretty sure everyone has seen at this point) that uses the dot product of the wheels velocity and the suspension direction. Originally I did it their way, and it worked for flat ground, but it breaks down the moment the vehicle has any vertical movement; driving up or down a hill for example. However, it is significantly less likely to shoot off, and usually just drives over small bumps seamlessly. This is I think only one of the causes however, as sometimes it still gets launched. I think this is due to the collider hitting the object, but this problem I don't know how to fix. How can I get the best of both of these methods of suspension velocity? I need to minimize the effect that small bumps have on velocity, while also not breaking down the moment I go up a hill.