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.
  2. Dismiss Notice

Question How do I make a custom wheel collider that doesn't just rely on motortorque?

Discussion in 'Physics' started by AceYTX, Jul 22, 2023.

  1. AceYTX

    AceYTX

    Joined:
    Feb 3, 2021
    Posts:
    6
    I'm currently in the process of trying to make a car game and I am using a custom wheel collider and want to stop only having motortorque as the only way to input a command to the wheel. I am instead trying to get the wheel collider to reach a certain rpm and using torque for acceleration and moving the car while it has a load. I have no idea how i would implement this though so I would appreciate suggestions and help.
     
  2. driftnumata

    driftnumata

    Joined:
    May 31, 2023
    Posts:
    29
    Is it like starting a manual car? Or like starting an electronic car?
     
  3. driftnumata

    driftnumata

    Joined:
    May 31, 2023
    Posts:
    29
    How did you get the wheels rpm? From wheel speeds?
    If you get the wheels rpm from wheels speed. I think you need to fix it there. Because the wheels are usually spinning idle.(It depends on the driver, location and case. But in the game world, the wheel is basically slipping← have you ever seen a tire not slipping in the game?) If you get the wheels rpm from wheel speed, the power does not go to the wheel enough, so it may be stocked.
     
  4. MrEuphrates

    MrEuphrates

    Joined:
    Aug 24, 2018
    Posts:
    1
    If I understand correctly, you want to use the wheel RPM as an input instead of the motor torque. If that's the case, you can calculate the force required and apply it to the Rigidbody of the vehicle and spin the tires separately using the Rigidbody.AddTorque method. To achieve this, I recommend implementing a suspension system that works with the rigidbody. You can find a great example of this in this video:
    . To calculate the traction force, you can use the formula F = Torque / Wheel Radius. For a more detailed understanding of the physics and calculations involved, you can refer to this resource: https://www.physicsforums.com/threads/calculating-wheel-torque-from-engine-torque.870677/#:~:text=Traction%20force%20%3D%20Torque%20%2F%20Wheel%20radius,by%2060%20seconds%20*%202Pi%20radians..
     
  5. AceYTX

    AceYTX

    Joined:
    Feb 3, 2021
    Posts:
    6
    It's meant to be a DCT so there wouldn't be a clutch and I'd most likely implement a script to convert it to automatic at a later date.
     
  6. AceYTX

    AceYTX

    Joined:
    Feb 3, 2021
    Posts:
    6
    I'm currently getting the wheel rpm from the angular velocity and I haven't noticed the wheels slipping.
     
  7. AceYTX

    AceYTX

    Joined:
    Feb 3, 2021
    Posts:
    6
    Thanks! I'll see if this solution works for me.