Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can this car physics be made?

Discussion in 'Scripting' started by Paulx774, Sep 17, 2021.

  1. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    Everyone probably knows or at least heard about Forza Horizon. I'm not making the same car physics in the game but I'm trying to achieve the car and the landscape interaction like in this video.



    When the car goes toward to the slope, the car doesn't crash into the slope. If you look at the car body, it should've crashed the landscape. Also, the car's velocity doesn't change much when it jumps. (From 250 to 200). There's same type of interaction in GTA 5 as well.

    I don't want any tutorial videos about wheel colliders because I have already made a realistic and an arcade car physics before but the behavior in the video is something I can't understand.

    You may suggest increasing the height of the car's collider but that would break the physics interactions between the others cars.

    You may think the landscape's collision is different that its visual. Yes, it is and it's obvious, however, if you look at the video, the car should've hit the landscape anyway even though the landscape collision is smooth.

    Does anyone have any idea?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    This is likely a custom arcade car controller that tracks and senses the normal of the ground and adjusts the car's velocity to properly curve upwards "just so." It almost looks like they overtrack the ground to simulate suspension compliance when the deflections are small, such as to keep you from going airborne over a tiny speedbump.

    I'd start with some arcade car controller physics tutorials, see where they get you. There's gonna be a lot of tweaking and twiddling as far as changing rates and sensitivities according to vehicle speed, height of bump compared to surrounding terrain, etc.
     
  3. Paulx774

    Paulx774

    Joined:
    Mar 18, 2021
    Posts:
    103
    This is likely a custom arcade car controller that tracks and senses the normal of the ground and adjusts the car's velocity to properly curve upwards "just so."

    Even though it tracks the the normal of the ground, it should've hit the slope before it detects the normal of the slope in my opinion. I can do the same thing by raycasting from the center of the car and rotate the velocity depending on the normal of the surface or by raycasting from the wheels and calculating the average of those normals, however, the car will still hit the slope as soon as the front bumber collides with the slope.

    It almost looks like they overtrack the ground to simulate suspension compliance when the deflections are small, such as to keep you from going airborne over a tiny speedbump.

    What do you mean by overtrack? By the way, I think, the suspension effect on the sand is fake. I don't think the landscape's collision is complex.

    Your first thought might work, but first there's a collision problem. The car's collider (from the front bumper) will always hit the slope. The car almost stops when going on slopes in my game. I tried changing the friction to 0 in the physics material, but it didn't work. It still slow downs the car
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Take height samples of the ground not only from where the car is but some distance ahead of it as well.

    If they detect only a small bump, they know to only wiggle the car around.

    If they detect a big launching-upwards ramp, they know to really give the car some vertical speed.

    Either way, using discrete Unity wheel colliders is not likely to get you this speed and functionality, unless you clock the physics update rate up super-super-high, like 200fps for instance, which right away limits what kind of hardware you can run this on.