Search Unity

Edy's Vehicle Physics - official thread

Discussion in 'Assets and Asset Store' started by Edy, Jan 19, 2012.

  1. seconddaytv

    seconddaytv

    Joined:
    Jan 22, 2020
    Posts:
    9
    Thank you for the quick response EDY!
    I currently experiment with the Randomation physics but I'll keep your physics in mind, should the Randomation physics not deliver what I need.
     
    Edy likes this.
  2. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    Hi, i have some vehicles setup with Edy's ;)
    I am wondering if i can move them to a single waypoint, ie they just need to drive forward.

    Ofcourse i could transform position the gameobject, but i was thinking using the physics and engine.
    I want to "start the engine" then let it drive on it's own, (only forward) until it reaches a target point, then engine off.

    Could that be possible?
     
  3. Luka201

    Luka201

    Joined:
    Dec 30, 2019
    Posts:
    4
    Capture1.PNG Capture.PNG eight-days-16.png Capture2.PNG Capture3.PNG
    Looks like the high poly Sport Coupe was from the cancelled game Eight Days.
    But how did that car end up in Unity?
    And what about the bus and the low poly Sport Coupe?
     
  4. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    111
  5. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Certainly, I'd love to have the high-poly Sport Coupe from those pictures! The one in EVP is not even close to that.
     
  6. soopx

    soopx

    Joined:
    Apr 3, 2021
    Posts:
    3
    Sooo, I bought this package today, and I've been struggling for hours to get where I want, but I'm unable to get the cars to behave how I'd like. I'm getting the sinking feeling that I may have purchased something I can't use to do what I want, but I was having a horrible time with the inbuilt wheel physics.

    Essentially I'm trying to re-create my simple game I made in Gamemaker Studio.

    I'd like my cars to:
    * never roll
    * accellerate quickly
    * never lose speed when cornering
    * drift, but never spin out

    So far I've just about gotten the accelleration by tweaking the mass to something very light, then maxing out the downforce, but I'm really struggling with the other three. Is it even possible?

    I'd also like the car to be bouncier, so it doesn't come to a dead stop after a collision
     
  7. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Hello! Please write me to edy@vehiclephysics.com for support. Thank you!
     
  8. pipboy3060

    pipboy3060

    Joined:
    Mar 31, 2013
    Posts:
    2
    Hey, for some odd reason, the game just freezes on startup whenever i hit play in editor. There's no obvious errors in the log that can point to anything. I tried making a new project and reimporting my custom made edy vehicle and the same thing happened.

    Any quick ideas about what to do? This didn't normally happen and usually my edy vehicle projects work perfectly.
     
  9. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    111
    I have bought many vehicle assets, this has to be the most realistic one. You can try out my game to see for yourself.
     
  10. play3dgamesonline

    play3dgamesonline

    Joined:
    May 24, 2021
    Posts:
    1
    Who can help why i see this when driving? its not rotating correctly!
     

    Attached Files:

    n00b_013 likes this.
  11. n00b_013

    n00b_013

    Joined:
    Dec 20, 2020
    Posts:
    14
    The pivot point of your wheels are not in the center. I had the same issue, when multiple meshes per wheel.

    You do best to create an empty holder gameobject, center this to the center of your wheel, and add the wheel gameobjects in there.
     
    Edy likes this.
  12. n00b_013

    n00b_013

    Joined:
    Dec 20, 2020
    Posts:
    14
    Is it possible to use the Vehicle Physics Pro (community edition) with a ps4 controller?

    Found the input settings earlier in this thread,

    Vehicle Standard Input -> Throttle and brake Input -> "Separate Axies"
    Project Settings -> Input -> in second occurence of Fire2 -> Positive Button "joystick button7"
    Project Settings -> Input -> in second occurence of Fire3 -> Positive Button "joystick button 6"
    Project Settings -> Input -> in second occurence of Jump -> Positive Button "joystick button 1"
    Project Settings -> Input -> in second occurence of Cancel -> Positive Button leave empty

    But I'm unable to find the first part, I see it only in the "simple" Edy's Vehicle Physics version?

    I have both, but I love the driving and handling of the pro version, so I want to use these with a controller. Anyone got this to work?
     
  13. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    If you mean using the triggers as throttle and brake, as far as I know you need some input mapper that can read those inputs separately. When queried as standard joystick (as Unity Input does) then triggers are combined into a single axis ("Vertical" IIRC).

    The paid versions of Vehicle Physics Pro include an input controller that supports XBox-compatible gamepads and can read throttle and brake from the triggers separately.
     
  14. n00b_013

    n00b_013

    Joined:
    Dec 20, 2020
    Posts:
    14
    Thanks a lot for the quick response!! Happy to hear it's possible in the VPP free version, though it's gonna be an adventure on its-own to get these working properly than.
     
  15. potatoandy

    potatoandy

    Joined:
    Feb 26, 2020
    Posts:
    3
    Hi Edy I have a quick question:

    According to the documentation, the maximum speed is determined by the "maxSpeedForward" and the "Aerodynamic Drag" settings. However no matter I set the drag to zero and how much I increase the "maxSpeedForward", the vehicle top speed is capped at around 150 to 160 km/h (checked with telemetry).

    Is there any other settings I could try? I need a top speed of around 300 km/h and it seems impossible to achieve.

    *** EDIT ***
    My setting for tireFriction is set to 3.0 to achieve an "Arcade style" driving style. However this seems to be the cause for the low maximum top speed.
     
    Last edited: Aug 29, 2021
  16. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That's odd. Those are the only parameters in EVP that limit the maximum speed. Please write me to edy@vehiclephysics.com and we'll take a closer look at the issue.
     
  17. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    123
    I'm trying to replicate the car movement over network. The replication of the transform-movement works already.
    I can also extract the speed and steering angle based on the transform-delta (I don't want to transfer this explicitly over the network). But how and where can I apply these values so that the wheels spin and steer, but this does not affect the rigidbody, etc. (so it should be only visually without any physics applied).
     
  18. unitynosf

    unitynosf

    Joined:
    Jun 9, 2014
    Posts:
    23
    Giving out a rough answer based on memory - as long as you make something like "VehicleNetworkInput" (on the basis on StandardInput) - and get inputs, you should get wheel visuals and steering and pretty much everything in the vehicle physics directly and act same as controller via keyboard. At least this is how we did it in past.
     
  19. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    123
    Thank you for your quick response.
    Currently I have the problem, that the car spins slowly around when trying to change the values for steering or changing the wheel's angular velocity. When using the input values I haven't found a way to just update the visuals and when changing the wheel-data directly to update visuals it almost works, except the car spins slowly around it's axis.

    When the "VehicleNetworkInput" would act like the StandardInput, how do you prevent that this input doesn't update the vehicle's position etc. so it does not override what the network sent as transform.position, etc.?
     
    Last edited: Oct 1, 2021
  20. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Hello, does anyone know how to make the brake button also work as reverse? Also, how can you do a stationary burnout?
     
    Last edited: Nov 13, 2021
  21. Grzzld

    Grzzld

    Joined:
    Aug 4, 2014
    Posts:
    12
    Thank you! And I agree with you, it is fantastic asset!
     
  22. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    is it possible to make these cars driveable on spherical planet?
    (maybe adjusting global gravity every frame, or manually setting gravity direction on car script?)
     
  23. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Yes, simply disable gravity in the Rigidbody and add your own gravity via Rigidbody.AddForce (with ForceMode.Acceleration) on each FixedUpdate().
     
    mgear likes this.
  24. jecs

    jecs

    Joined:
    Aug 29, 2014
    Posts:
    2
    jecsCapture.PNG Hi Edy,
    I have an 8 wheel vehicle where 4 forward wheels are all turning at the same time and angle. But I need the second pair behind to turn at another less pronounced angle, maybe half (right now the vehicle jitters when turning). I may try to modify the script, but I am a beginner with C#, or should I try the Pro version? Thank you
     
    Last edited: Jan 28, 2022
  25. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That vehicle is really cool!! Where did you get it?

    EVP doesn't provide such steering options. If you're willing to modify a working C# script you should really get some experience in C# first. I can't help you with that, but there are plenty of tutorials, examples, exercises, courses and documentation out there.

    As for Vehicle Physics Pro (it's a different package, not a version of EVP) your steering layout could be configured easily out of the box, but you would need a Professional license to set up more than 4 wheels in a single vehicle.
     
    jecs likes this.
  26. ishangill

    ishangill

    Joined:
    Nov 28, 2017
    Posts:
    36
    Hello .
    I want to create exhaust smoke system.
    How can I create this.
     
  27. jecs

    jecs

    Joined:
    Aug 29, 2014
    Posts:
    2
    Thank you for answering Edy,
    I have been a fan of your vehicle physic system in Unity from the beginning years ago, but it was more a hobby to me. However, now I am trying to integrate functionality to my models and of course I love all kind of vehicles and wheels and playing with EVP in Unity is my way to go. I created the vehicle and it is great you like it Edy!

    Ok I get it. I have some experience with C# and I have successfully modified and added some custom functions to EVP in the last months, so I will try to solve how to make the wheels turn at a different angle. It is just I am not a dedicated programmer and it takes me some time to figure it out. As for the Pro version being different than EVP and requiring a license I will leave that as a last option. Thank you Edy
     
  28. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    Thanks, that works, after changed Vector3.up from few scripts also.

    Any plans for adding new input system support?
     
  29. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    I don't plan to include scripts that use the new Input System because it's not part of the Unity API, so it's not guaranteed to be available in every project.

    Still, vehicles in EVP expose their inputs as plain C# properties in the VehicleController component (steerInput, throttleInput, brakeInput, handbrakeInput), so it's very easy to map the new Input System (or any other input system) to modify their values.
     
    mgear likes this.
  30. levelappstudios

    levelappstudios

    Joined:
    Nov 7, 2017
    Posts:
    104
    Hi, I'm using EVP for a while and it's fantastic.

    Is there a way to rev the car's engine while it's not moving?

    Thanks in advance-
     
  31. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    No, the engine rpm is calculated out of the wheel's rpm. You'd need to modify VehicleStandardInput and VehicleAudio to implement that feature.
     
    levelappstudios likes this.
  32. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    509
    Hi it doesn't work anymore after updating to unity 2020.1.17 and set active input handling to "Both"
     
  33. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Any error message, symptoms, etc...?
     
  34. levelappstudios

    levelappstudios

    Joined:
    Nov 7, 2017
    Posts:
    104
    I was working in another game since the answer of this question and didn't try the solution until now. Modifying those scripts worked as you said, thanks!

    I got another question. Is there an easy way to calculate the car grip (approximately)? I have read the FAQ and there are a lot of parameters for handling:
    • All parameters in "Vehicle Balance"
    • All parameters in "Driving Aids"
    • Anti-roll
    • Max Drive Slip
    • Drive Force To Max Slip
    • Center of Mass (Position and Height)
    What I am looking is: "how good is this car taking a curve?". I am trying to code a function like this:

    Code (CSharp):
    1. // Returns grip factor [0, 1]
    2. float GetCarGrip()
    3. {
    4. float grip;
    5.  
    6. // ...
    7.  
    8. return grip;
    9. }
    Any ideas about this? Thanks in advance
     
  35. menguzar

    menguzar

    Joined:
    Jan 31, 2022
    Posts:
    10
    Hey, I'm trying to do about the same thing. particularly the "never lose speed when cornering" part.

    did you manage to get it to work?
     
  36. Paul-van-der-Laan

    Paul-van-der-Laan

    Joined:
    Oct 12, 2013
    Posts:
    60
    Hello @Edy ,

    I'm trying to use EVP on a long road (16km) and thus I'm looking into floating origin solutions. I tried Floating Origin Ultimate but unfortunately when the origin is shifted, the car either stops or gets a pull on the steering wheel (both with and without 'disable colliders on recenter' enabled).

    I see you a made a fix for Vehicle Physics Pro, is such a fix also available for EVP?

    Or do you have any other suggestions?
     
  37. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    I haven't tested floating origin support in EVP yet, but it will come eventually. If it helps, my floating origin solution is based in this script properly arranged and adapted: https://web.archive.org/web/20210507024450/https://wiki.unity3d.com/index.php/Floating_Origin
     
  38. Paul-van-der-Laan

    Paul-van-der-Laan

    Joined:
    Oct 12, 2013
    Posts:
    60
    Thank you for your quick reply, Edy.

    I tried the script from the wiki but unfortunately it displays the same unwanted behavior as with the Floating Origin Ultimate script. When the origin is shifted, the car's steering gets a sudden pull to the right. See below video at the 5s mark when the origin is shifted:



    Also I have another question which is not fully related to EVP but as a Unity car controller expert, I hope you can help me. I'm trying to setup a Logitech G29 and I wonder if I need to write a wrapper script myself to link the input from the Logitech SDK to EVP or whether this should work out of the box. I noticed the following behavior from my G29:

    -The clutch pedal is affecting the Vertical axis in the (old) input system.
    -The steering wheel is affecting the Horizontal axis, but there is a massive dead zone of 180 degrees. I need to turn the steering wheel beyond 90 degrees before there is any effect on the Horizontal axis. Is this normal?
    -the brake and gas pedal isn't affecting any axis in the input system by default. I can see they work however by using the LogitechSteeringWheel.cs script.

    Do I need to change my setup to make the G29 work better out of the box? I'm using Unity 2021.3.5f1, Logitech Gaming SDK 1.7 from Asset Store (replaced LogitechSteeringWheelEnginesWrapper.dll as mentioned in reviews) and have Logitech G-Hub 2022.8.306864 and Logitech Gaming Software 9.04 installed.
     
  39. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    I see, thank you for the video. Definitely that needs a fix. Noted.

    I'm afraid I can be of little help here. I had tried Logitech SDK long ago and it was way too buggy to be usable. I ended developing a native C++ wrapper for accessing DirectInput from Unity, which supports just any brand and device. The latest version learns and configures the inputs on the fly in runtime.

    Still, feel free to write me to edy@vehiclephysics.com and we may find some solution suited to your case.
     
  40. Paul-van-der-Laan

    Paul-van-der-Laan

    Joined:
    Oct 12, 2013
    Posts:
    60
    Thanks for the help, Edy. I managed to make my Logitech G29 wheel work with Unity by reinstalling G-Hub so it detects my steering wheel again and wrote the simple script below which suits my current needs.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using EVP;
    5.  
    6. public class LogitechEVPInput : MonoBehaviour
    7. {
    8.     private float normalizedWheelValue;
    9.     private float normalizedThrottleValue;
    10.     private float normalizedBrakeValue;
    11.  
    12.     [SerializeField] private VehicleController vehicleController;
    13.  
    14.     private void Start()
    15.     {
    16.         Debug.Log("SteeringInit:" + LogitechGSDK.LogiSteeringInitialize(false));
    17.     }
    18.  
    19.     private void Update()
    20.     {
    21.         if (LogitechGSDK.LogiUpdate() && LogitechGSDK.LogiIsConnected(0))
    22.         {
    23.             LogitechGSDK.DIJOYSTATE2ENGINES rec;
    24.             rec = LogitechGSDK.LogiGetStateUnity(0);
    25.          
    26.             //Steering wheel
    27.             normalizedWheelValue = rec.lX / 32768f;
    28.             vehicleController.steerInput = normalizedWheelValue;
    29.  
    30.             //pedals are considered separate, not combined in G Hub settings
    31.  
    32.             //Throttle pedal
    33.             normalizedThrottleValue = ((rec.lY / -32768f) + 1) / 2f;
    34.  
    35.             //Brake pedal
    36.             normalizedBrakeValue = ((rec.lRz / -32768f) + 1) / 2f;
    37.  
    38.             vehicleController.throttleInput = normalizedThrottleValue - normalizedBrakeValue;
    39.         }
    40.     }
    41. }
    42.  
     
    Edy likes this.
  41. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Cool, thanks for sharing!
     
  42. Paul-van-der-Laan

    Paul-van-der-Laan

    Joined:
    Oct 12, 2013
    Posts:
    60
    Do you have a fix planned soon or a work around? I would like to explore the possibility of a very long straight road without hick-ups with EVP.
     
  43. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    Edy, been having a blast incorporating the EVP onto Synty Polygon vehicles. For all the standard vehicles, it's been going swell. Slightly different audio, slightly different weight and drive characteristics, they all seem to make sense and it's been smooth.

    Synty offers a free mesh on their store for a Quad Bike. Go check them out. But for some reason, the same integration process for the Quad allows the bike tires to squeal and the whole model slips to the side, with zero throttle, even on your perfectly level test scene.



    I'm a little comfortable with your script at this point. Where would I look to troubleshoot this? Or if you grab that Quad model, let me know if you have the same behavior.

    ETA: Looks like something about the suspension being too strong for 300kg rigidbody weight. Anything under 500kg, and I can see your slip gizmos start to vibrate nearly half a meter left, half a meter right, every frame. I can live with 500kg if we can't make the suspension adjustable.
     
    Last edited: Nov 21, 2022
  44. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    @halley maybe there's no collider in the model? Also, you may adjust the suspension spring and dampers in the wheel collider. These should be proportional to the vehicle's mass, so if this vehicle has like 1/3 of the typical vehicle, then multiply spring and damper rates by 1/3.
     
  45. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    I put colliders on, just like other vehicles. I will definitely look into the wheel collider parameters this afternoon. Sounds like it's easier than I thought to adjust.

    Slight difference from my other car models: the wheel colliders are auto-moved to be inline with the wheel mesh pivots, but I would like them to be inline with the center of the tire mesh bounds for more realistic wheelbase. I tried using empties to offset but must've gotten something wrong because tire meshes moved down so the hub was on the ground.
     
    Edy likes this.
  46. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    Replying to my own post. I dialed the springs down from 37000 to only 8000 or so, and started bumping up things like traction as well, for a vehicle like this. I did get the wheel offset empties worked out properly-- the position of the wheel colliders isn't at the center of the gizmo ring, but above it to represent the spring midpoint. I now have the wheel colliders just outside the center of the rubber. Expanding that wheelbase is definitely necessary to avoid toppling even more than these vehicles are prone to do in reality.
     
  47. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    I haven't seen an exact recipe in this thread or by Google, but I found that an Edy's Vehicle Controller will correctly handle a semi tractor trailer, including all the tire-slipping traction, which a WheelCollider alone will not do properly. I gave the trailer its own EVC and audio, configured with the right number of wheels, specified that none of the trailer wheels are "drive" tires, and used a Configurable Joint (with every axis locked but X and Y Rotation) at the fifth wheel kingpin.

    It took a few tries to get the right spring and damping figures for the wheels, so they weren't crushed or bouncy. If the weight is enough, you can even get a good amount of "tugging" torque effects on the tractor (pitch only, not twist).


     
  48. BusterTheWizard

    BusterTheWizard

    Joined:
    Jul 2, 2012
    Posts:
    55
    Is there an integration for Wheel Controller 3D? If not would it be difficult to integrate?

    Currently need it because of the terrain I have, but it's going to be difficult to integrate with RCC. On the fence about purchasing EVP, if it is easy or already possible to use this 3d wheel collider asset I am sold.

    https://assetstore.unity.com/packages/tools/physics/wheel-controller-3d-74512
     
  49. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Rotation should be free around X, Y and Z. Twist effects are also necessary so the trailer can drive over bumps and tilt around the Z axis.
     
  50. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    I can't tell for sure. EVP uses the built-in WheelCollider internally configured in a very specific way for a correctly working suspension, but it doesn't use the WheelCollider tire friction at all (all friction parameters are set to zero).

    While the feature list for Wheel Controller 3D states "API with almost no differences from Unity's inbuilt WheelCollider - familiar and easily swappable", EVP doesn't use the WheelCollider in the expected standard ways. Just swapping the components may or may not work.