Search Unity

Wheel Collider adapt speed

Discussion in 'Physics' started by adriank5, Oct 23, 2017.

  1. adriank5

    adriank5

    Joined:
    May 22, 2017
    Posts:
    7
    Hey guys

    I'm wondering if it's possible to change the speed at which the suspension of the wheel collider adapts to new heights? It is most obvious when driving over numerous small obstacles - the wheels just pop into the new height at the lightspeed and I'm not sure if it's 100% because of the WC raycast method or is there something else. Obviously I'm not talking about the spring settings as they don't seem to have any effect on this particular problem.
     
  2. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Hmmm, I'd imagine the spring settings would be exactly what you're looking for.

    What settings have you tried? What are the WC settings at currently?
     
  3. adriank5

    adriank5

    Joined:
    May 22, 2017
    Posts:
    7
    The thing is that so far it seems to me that no matter the spring settings, the speed at which the wheels readjust after sudden change of height is the same.
    Code (CSharp):
    1.     private float springStiffness = 35000;
    2.     private float springDamper = 1500;
    3.     private float springTargetPosition = 0.5f;
    4.  
    5.     private float suspensionHeightOffset = 0.5f;
    6.     private float suspensionTravel = 1.0f;
    7.  
    8.         private float wheelMass = 35.0f;
    9.  
    10.  
    The tank itself currently has only 1 rigidbody with 3000 unit weight. I'll slap another video up to show how changing the spring settings doesn't help at all.

    By the way - would you happen to know what exactly does the wheel damping parameter do? I've failed to produce any results by changing it to even cosmic values.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Wheel Collider is raycast based so it will always pop. This is desired in this case. what you do is separate the visual from the collider, and lerp the visual (mesh/gameobject/transform) so it doesn't pop. So don't put the mesh on the same object as the collider.

    That's how things are done in games usually, expect to run physics or networking at different rates varying quality, while taking care to present the visuals in a nice controlled way.
     
  5. adriank5

    adriank5

    Joined:
    May 22, 2017
    Posts:
    7
    Thanks for the reply. Well the wheels already take the WC rotation and position. I don't really feel like hacking the lerp of visual mesh because the tank will still behave how it behaves (which is terrible thanks to WC's) so I'll probably just consider buying the 3D wheel collider asset which also won't make my vehicles warp around and explode whenever the vehicle happens to drive on the "side" of the wheel collider.
     
  6. Fu11English

    Fu11English

    Joined:
    Feb 27, 2012
    Posts:
    258
    Why not just use a custom cylinder collider + rigidbody for each 'wheel', and a config joint to limit it's motion up and down (and spring). Then script the forces yourself, there's a simple physical wheel collider script HERE to get you going without needing to buy a package.

    I have modded that code before to get an arcade style motorbike working which can do donuts and stuff, so a tank should be pretty easy.
     
  7. adriank5

    adriank5

    Joined:
    May 22, 2017
    Posts:
    7
    Thanks, yes sure I can try doing that, it's a good alternative to shelling out the money. I'll see into it I think the topic can be considered done really, as it seems there's no way of fixing the behaviour described in the first post, using the default wheel collider. Thanks for the replies guys :)