Search Unity

Randomation Vehicle Physics 2.0 - Now open source on GitHub!

Discussion in 'Assets and Asset Store' started by JustInvoke, Mar 14, 2015.

  1. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    When you say hard limit, do you mean like the wheels aren't steering all the way or that the tires are just slipping when you turn too much. I know having the tires slip at high speeds has been a long-running issue but there isn't really a simple fix beyond trying different combinations of values. You've probably already tried this, but the first thing I would recommend is raising the right end of the sideways friction curve (the part following the peak). This is essentially the friction factor applied when slipping.
     
  2. seconddaytv

    seconddaytv

    Joined:
    Jan 22, 2020
    Posts:
    9
    Hey!
    Yes, the sideways friction of the front tires actually seems to be the issue here, figured this out yesterday and already played around with the values. I actually got some pretty decent results but I am not 100% satisfied yet. I didn't think about adjusting the curve though, so I'll definitelly try that out, thank you very much for still answering questions here, highly appreciate it!

    Talking about questions, I actually have another one :D Sometimes when the a car lands after a large jump it instantly slips away, I have the feeling this is caused by the suspension not being strong enough, but couldn't find a fix yet. I'll try some things out by myself, but if you have any idea how I could possible fix this, I'ld love to hear it.

    Thank you! :)
     
  3. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Sorry but I'm not really sure what could be causing the car to slip after a large jump. The suspension shouldn't have anything to do with it because all of the friction calculations are done by the wheel.
     
    seconddaytv likes this.
  4. Taku-chan-gamer

    Taku-chan-gamer

    Joined:
    Nov 18, 2019
    Posts:
    32
    i have 2 problems with this its good exept i have no idea how to fix them 1st ai chase cars (the damage one) likes to teleport inside players car causing lag on the ones that do take damage and the just fling on the others 2nd i made a custom car and it wont move if someone can help thats fine it steers and brakes (i think) it works fine o
     
  5. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Can you share a video of your problems? Your custom car might not be driving because the engine, transmission, and suspension components may not be connected properly. Make sure the output drives on the engine and transmission contain references to the components they should send drive force to. You can look at the included prefabs as an example.
     
  6. seconddaytv

    seconddaytv

    Joined:
    Jan 22, 2020
    Posts:
    9
    Hey JustInvoke,
    I currently encounter an issue where the tires of my car seem to sink into the ground for a very short moment whenever I drive into a slightly tilted part of my track.
    I currently can't really figure out why this happens, maybe you have an idea?
    Here is a short clip, where you can see what I mean!

    Thank you in advance :)
     
    junaid109 likes this.
  7. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    You should try increasing either the hard contact force or hard contact sensitivity (or both) on the Suspension scripts. It's not perfect, but the hard contact force is another force on top of the suspension spring force that attempts to prevent wheels from clipping into the ground when the suspension is fully compressed. This is necessary since the physics engine doesn't have a reasonable way to simulate custom hard collision forces without the use of colliders (to my knowledge), and colliders aren't suitable since they will cause the car to get stuck or launched when sliding against ground geometry.
     
  8. seconddaytv

    seconddaytv

    Joined:
    Jan 22, 2020
    Posts:
    9
    Mhh, unfortunately that doesn't seem to fix my issue :(
    Thanks for the quick answer though, I ll try to experiment a little more with the suspension, maybe I'll find a workaround.
    Overall, the suspension seems to be oversensitive with some meshes, meaning it acts like there are small bumps in the track while driving over plane surfaces like in the video. (this mostly happens in steep curves or loopings)
    Do you have an advice on how to tackle this? :D
     
  9. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The only thing I can think of is increasing the spring dampening. It's hard to know what to adjust without trying it myself.
     
  10. seconddaytv

    seconddaytv

    Joined:
    Jan 22, 2020
    Posts:
    9
    That's understandable, thank you nonetheless!
     
  11. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Thanks for making this available. Playing around with the F1 car, I was wondering about friction in the demo scene. Shouldn't the car lose speed at a much more rapid rate when I release the controls, as it is right now it maintains the speed for a long time? Is this something that I should assign to the ground or tweak the wheels?
     
  12. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    You can either increase the drag of the rigidbody or the axle friction of the wheels (Wheel script).
     
  13. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Thanks!
     
  14. yaman3bd

    yaman3bd

    Joined:
    Nov 8, 2017
    Posts:
    2
    hi
    I really like the physics that you made and making it free it is absolutely amazing thanks a lot
    but I have few questions
    1-how can I make the car upgradable such as top speed, acceleration, start acceleration, and nitrous?
    2-I'm making a hyper-casual darg racing game do you is it recommended to use the physics of the cars in my game?
    but however, I'm really interested to know how can I make the car upgradable as I mentioned in the 1.st question
     
  15. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    You would have to create your own system for serializing upgrades (like a ScriptableObject) then modify the vehicle scripts to apply those properties to their own variables.

    You can use these physics to make a drag racing game if you want but you don't really even need actual physics if your cars are just going to drive in a straight line and can't steer or crash.
     
  16. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Noticed that the F1 car doesn't accelerate in upwards slopes. The slope isn't that steep, is there a way to make the acceleration work better in upwards slopes?

    Any suggestion on how to simulate tire degradation or heating tires. Degradation could maybe be the Tire Pressure or any better idea?
     
    Last edited: Jul 16, 2021
  17. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    I just tested the F1 car and was able to accelerate while driving up the mountain in the demo scene. Maybe it has something to do with the physic material on your terrain?

    What effect do you want to happen with tire degradation? The tire simulation is pretty basic and you will have to manually adjust the properties you need to get the effect you want.
     
  18. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Hm, remembered I had changed the gravity since the cars jumped a lot on the track and it felt floaty. That was the issue. Will have to think about something else to keep them more grounded.

    Would like the cars to lose some grip and lower the top speed of the car.
     
  19. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    You could try adjusting the normal friction curve (copied from the manual):

    Normal friction curve – Adjusts the friction of the wheel based on the dot product of the ground surface normal and the global up direction. X-axis = normal dot product, y-axis = friction multiplier. This is useful if you don't want vehicles to grip walls or steep slopes easily.

    For your case it's the opposite where you want more grip on steeper surfaces.

    To reduce the grip you can just lower the forward and sideways friction. To lower the top speed you would have to adjust the engine (GasMotor) which is more complicated due to how it's designed. The width of the torque curve and the transmission gear ratios determine the top speed. Unfortunately customization isn't something I had in mind when I developed this.
     
    Last edited: Jul 16, 2021
  20. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Thanks! Will try it! But that will affect both downwards and upwards friction right?
     
    Last edited: Jul 16, 2021
  21. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Another quick question. If you want to create something like a gravel trap where the car loses a lot of speed, is that something that is possible with the current features?
     
  22. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    I believe that's the case, so you will also accelerate faster downhill.
    I don't think anything specific to my system will forcibly reduce the speed. Your best bet is likely to increase the drag of the rigidbody while it's on a gravel trap.
     
  23. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Ah, sounds like a good idea. Thanks!
     
  24. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    80
    I got the project up and running in Unity. I notice the wheel rotation just matches the speed (unless the handbrake is on). How feasible would it be to make the wheels spin based on engine force and friction, i.e. burnouts if I put the accelerator fully on from standstill? Would that require a reworking of the physics? Thanks!
     
  25. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Burnouts already are possible if you hold the regular brake and accel at the same time, and the wheels can slip and spin faster if the torque is too great. However the wheel simulation is fairly limited since it basically lerps the rotation rate between what it would be based purely on the speed of the car and what it should be based on the torque. The ApplyDrive() function inside the Wheel class is what controls this.

    If I had it to do over again I would have simulated wheel rotation by applying angular acceleration to them based on torque and friction forces. This would also have the benefit of giving wheels some inertia and a sense of weight which they currently lack.
     
    FissicsPeep likes this.
  26. Paraseven

    Paraseven

    Joined:
    May 12, 2022
    Posts:
    1
    Hello,
    I found your kit around 1 year ago and i love it, it helps me a lot but I just need one thing that i cant manage to do.
    So, at a certain condition i need to make the car brake by itself but I cant find how to do it.
    I search up how the brake system works but I found nothing it would be great if you help me please.
     
    Last edited: May 12, 2022
  27. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The best way to control the brake is by calling VehicleParent.SetBrake() with a value from 0 to 1 representing the brake input. The FollowAI script is an example of this where an AI car tries to slow down to steer and drive towards a waypoint.
     
  28. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Hey all, has anyone managed to fix the engine sound wobble? Even with the realistic engine sound asset it still wobbles, which makes me think it's something to do with the RPM calculations.