Search Unity

Edy's Vehicle Physics - official thread

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

  1. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Hey Edy. Is there a way to make the wheel steerangle change less quickly? I'd rather have half turning power at like 60 mph rather than 20.
     
    JamesArndt likes this.
  2. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Is there a C# version of the project?
     
  3. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    Hey Edy,

    Is it possible that the car behavior changes on different surfaces?
    Like when you go from road on a grass surface.
     
    Last edited: Nov 6, 2014
  4. pavel_stupka

    pavel_stupka

    Joined:
    Jan 28, 2014
    Posts:
    7
    I haven't found any documentation for CarSound script? Is there any?
     
  5. timmay2t

    timmay2t

    Joined:
    Sep 12, 2014
    Posts:
    6
    Hi Edy, i've been working on a dirt oval set of physics and have been able to accomplish what i wanted for the most part but i'm having 1 issue and i just can't seem to sort it out. When i go into the corner, if you release throttle the car instantly spins out to the left. Almost like the rear tires are locking up or the car is wanting to go into reverse. Rolling friction slip is at 0 and i can confirm the tires are not locking up, as they are still moving even though that's what it feels like the car is doing. Any thoughts?
     
  6. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Also, I'm assuming work is being done to allow these to work properly in U5? As of now, the car does a lot of strange things and is undrivable in it. :p
     
  7. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Please share:
    1) Unity 5 news
    2) C# project asset

    They will be very appreciate :)
     
  8. hasol

    hasol

    Joined:
    Nov 8, 2014
    Posts:
    1
    hi Edy
    İf you put mobile controller example ,you die?
    a lot of question for mobile controller but you :(
     
  9. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365
    Hi i cant be bothered to read through all 11 pages so ill ask here has anyone managed to make it so you can get in and out of vehicles?
     
  10. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    Just a quick question, but does anyone have an AutoSteer function that works with Edy's stuff here? I'm working on a drag racing game, and my own attempts at making an AutoSteer function doesn't seem to be working quite so well. My cars seem to be flipping around a bit, if I try locking the Z rotation with or without the AutoSteer they will do a quick 180 turn, and when I try to lock the other rotations and let the AutoSteer handle Z I do a 65m /s wheelie down the track.

    Also Edy, as you are already redoing the entire package for Unity 5, could you please do the work in C# please? I'm asking this because JavaScript scripts are really the same thing as C# scripts with less rigid controls built into the framework, and compiling the JavaScript files, even when I just click on the Play button seems to take quite a bit longer than if I was using only C# scripts for a game.
     
  11. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    Never mind that part, I figured out how to get my auto steer to work. I had the motor powered way too much for the model I was using.
     
  12. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    Any update on the terrain sliding?
     
  13. Smartline-Games

    Smartline-Games

    Joined:
    Aug 15, 2013
    Posts:
    67
    Hello Edy,

    Is this topic still up and running? If yes, I would like to ask you a few questions.

    P.S. I'll check this topic another time to see if it is still 'active'.
     
  14. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi Edy,

    1) question to the pro version.

    I require a robust and easy fast car physic,
    without wheel spin/slip
    without viscosity
    without differential type
    without engine friction,
    etc..

    Would you include good old fast and clean mode for the Pro version?

    Thanks.
     
  15. Farlas

    Farlas

    Joined:
    Sep 20, 2012
    Posts:
    9
    i'm still trying myself to script this but no success for moment so if someone have a working enter/exit for edy's i will thanks him a lot.
     
  16. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    I'm trying to control the vehicle speed from a slider for my drag racing game, and I thought that what I was supposed to do was affect the motorInput so I added to the Update function a couple lines that should apply the slider's value if the car was enabled. However after I made sure that the car knew were to get the slider's value from by making slider a public Slider with the new UI included, the car just sat at the start position. What am I missing?
     
  17. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365
    hi i made my own its really easy just disable car control script and the audio on the car then on your player make it so when he either enters a trigger or raycast hits the car he will enable those car controlls and audio and then disbable his camera and controlls ect then when he wants to leave the car you press a key then it enables all of those and disables the car and moves the player to a position outide of the car
     
  18. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    I want to make my cars tiny, but when I set the scale to 0.1 then they behave very strangely. I have tried adjusting things to fix it but I cannot work out what I need to tweak to make them feel right again. Whats the easiest way to make them small ?
     
    Last edited: Nov 17, 2014
  19. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    Hi,

    Can anyone guide me on how to add mobile inputs.?
    - I have imported Standard assets(Beta) in project.
    - Enabled Mobile Inputs
    - Dragged "Mobile Car Tilt Control with Buttons Rig" prefab

    Tried changing code(CarMain.Js) from

    "var forwardValue = Mathf.Clamp(Input.GetAxis("Vertical"),0,1);"
    to
    var forwardValue = Mathf.Clamp(CrossPlatformInput.GetAxis("Vertical"),0,1);

    But getting error "BCE0005: Unknown identifier: 'CrossPlatformInput'."

    it seems Js not communicating C#(CrossPlatformeInput)...Dont know..??!!

    Can you share your work-flow for mobile inputs please ....

    Thanks..
     
  20. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    I personally don't use any of the "standard imports". Currently I am attempting to use Edy's for mobile using Unity 4.6, and I am trying to tie the throttle to a Slider. I can't seem to find the part of the code though that Edy used to tell Unity to tie it to the W key.

    If you want to use C# you should communicate with Edy via PM and get an account for his website. My boss did that, and we are using 4.3 for our current game.
     
    Last edited: Nov 17, 2014
  21. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Sorry everyone. I wasn't been notified on new posts on this thread. I'm having a hard time trying to catch up the email due to the latest Asset Store sale. I'll be replying here asap (please don't re-send your question by email! pretty please! :p)

    Meanwhile, most questions regarding Unity 5 and future plans are answered at the FAQ at the end of this post:
    http://www.edy.es/dev/2014/11/early-preview-of-vehicle-physics-pro/

    In addition, I've created the twitter account @VehiclePhysics. Follow it for getting notified on news and updates on my vehicle physics products.
     
  22. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    Ok, well I found the throttle control in the CarMain script. It's good to know that you are working on the U5 version Edy.
     
  23. Farlas

    Farlas

    Joined:
    Sep 20, 2012
    Posts:
    9
    i just notice at end of first page you share a CarLights scrip so i put the CS in same folder as other CS and the shader in folder with shader (vehicle folder) but unity give me message :

    and this is what i have at line :

    edit : nvm i just see that all script are in JS and the carlight are CS
     
  24. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    First round of answers:

    No, that was a different project. But I can share the specific settings used for the Ferrari (mail me with your invoice no.). Hint: the model is virtually identical to the Sport Coupe. Only some settings at the WheelColliders and the position of the center of mass had changed.

    The property "Esp Level" in CarSettings limits the steer angle depending on the actual velocity. It has effect when Esp is enabled. The angle is limited to the value that matches the peak sideways friction for the actual vehicle speed. The "Esp Level" value enforces or relaxes this limit. Esp Level = 0 is the same as disabling Esp.

    If you want to modify rate of change of the steering angle, this depends only on the standard Input settings (Project Settings > Input > Horizontal > sensitivity / gravity).

    Starting at version 4.4 the scripts can be used from C# code directly. Simply move the folder EdyVehiclePhysics/Scripts to the Plugins folder in the root of your project (create it if doesn't exist). The previous C# version is no longer updated due to the difficulties of maintaining two versions. I've kept the JS version because it's the language originally used for writing the scripts, but it can be used from C# code without any problem.

    Still, you can request the latest C# version available (4.3) by mailing me with your invoice number.

    That's how it actually works. Check out the demo:
    http://www.edy.es/dev/vehicle-physics/live-demo

    Answered at the FAQ at the end of this post:
    http://www.edy.es/dev/2014/11/early-preview-of-vehicle-physics-pro/

    I don't think my package is the most appropriate for doing such projects. They don't require true vehicle physics, but some "simple" forces and frictions acting on the vehicle. Edy's Vehicle Physics applies forces on each wheel, and the sum of them make the actual behavior of the vehicle. It would be easier for an arcade game to code the forces acting in the body directly.

    Looks like I forgot to write it. It was an upgrade to the original version. Noted.

    Enable the Telemetry component and check out the curves for figuring out what's happening at that situation. In the demo scene provided with the package the curve Telemetry is displayed pressing B, then shift-B. A detailed explanation of the telemetry values and graphs can be found here:

    http://www.edy.es/dev/vehicle-physics/live-demo
    (see the bottom of the post)

    Early preview of my upcoming package for Unity 5. Check out the FAQ at the end of the post:
    http://www.edy.es/dev/2014/11/early-preview-of-vehicle-physics-pro/

    1)
    http://www.edy.es/dev/2014/11/early-preview-of-vehicle-physics-pro/
    Also follow @VehiclePhysics on twitter for news and updates.

    2)
    Starting at version 4.4 the scripts can be used from C# code directly. Simply move the folder EdyVehiclePhysics/Scripts to the Plugins folder in the root of your project (create it if doesn't exist). The previous C# version is no longer updated due to the difficulties of maintaining two versions. I've kept the JS version because it's the language originally used for writing the scripts, but it can be used from C# code without any problem.

    Still, you can request the latest C# version available (4.3) by mailing me with your invoice number.

    Actually my package doesn't include a controller for mobile devices. It's required to import a third-party controller and adapt it. There are many solutions out there, and each projects requires a specific approach.

    You can find more hints on how to adapt a mobile/touch controller at the FAQ in the first post of this thread:
    http://forum.unity3d.com/threads/edys-vehicle-physics-official-thread.120091

    The new package is already 100% C#.
     
    Hormic likes this.
  25. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Second round...

    No, sorry. Looks like something have changed at some point since Unity 3 -> Unity 4. I don't remember having that problem at Unity 3, but soon I switched to use meshes instead of terrains and I hadn't experienced that problem again. Looks like the small terrain used at the demo scene is not enough for exposing the issue.

    Not sure on what do you mean here. For the above requirements you don't even need a vehicle physics package. Just put together a rigidbody, 4 WheelColliders without friction (stiffness = 0), apply forces or impulses to the body directly, and you have it.

    Maybe the gearInput parameter? The default 0 value is neutral, so the vehicle won't move. Set it to 1 for forward, and -1 to reverse.

    Make everything else big! (scale 10)

    Vehicles and scales don't fit well. Surely you can scale one of the provided vehicles by 0.1, but you'll have to completely configure and fine tune it from scratch.

    1) Follow the instructions at the Readme for moving the scripts folder in order to make them accessible from C#.
    2) Use an external script for controlling the vehicles instead of modifying CarMain, and send the values to the input parameters of the vehicles (motorInput, gearInput, brakeInput, etc).
     
  26. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    I just PM'd you a simple example project that shows the issue. Please let me know what you find.
     
  27. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Ah real shame you cant resize it, I cant resize my world to x 10, theres many reasons I cant. I always find it strange that scale is such an issue in unity. So basically I cannot use this asset, the whole purpose was to have tiny toy cars.
     
  28. Farlas

    Farlas

    Joined:
    Sep 20, 2012
    Posts:
    9
    hello,

    there is a chance to get the CarLights in JS format ? cause in the zip its a C# (i'm not programmer so i can't transform CS to JS myself).

    Thx by advance.
     
  29. Wonderis

    Wonderis

    Joined:
    Jul 22, 2013
    Posts:
    3
    Hi, any way of playmaker support for non programming? Especially for mobile touch gui controls.
     
  30. Alex_V

    Alex_V

    Joined:
    Jun 25, 2012
    Posts:
    53
    Does anyone have a drift "setup" willing to share?
     
  31. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    For drifting, reduce the wheel slip in the CarControl and turn off TC in the CarSettings.
     
  32. break_heart

    break_heart

    Joined:
    Oct 16, 2014
    Posts:
    12
    Hello,

    Can simulate a radio controlled buggy or TT?

    The main features are:
    - Only a gear
    - Very fast acceleration
    - Do not overturn too fast for you to take the curve

    For example:


    Other question, Does it integrate with any assets of AI?

    Thanks.
     
  33. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    Has there been any update on the terrain sliding bug? Did the example project I PM'd you hold any answers?
     
  34. Fahrettin

    Fahrettin

    Joined:
    Mar 10, 2014
    Posts:
    81
  35. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    I got it to work with the unity sample assets(4.6), Fahrettin.
     
  36. Fahrettin

    Fahrettin

    Joined:
    Mar 10, 2014
    Posts:
    81
    Can you explain how you can achieve implementation ?
     
  37. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Edit the Input values in the Main script.
     
  38. Fahrettin

    Fahrettin

    Joined:
    Mar 10, 2014
    Posts:
    81
    Sorry for late reply. I looked script but i cant get which one is forward input. Comments are not in english.
    If i have option i could refund this purchase. Its hard for me to work with it. :(
     
  39. Davidbillmanoy

    Davidbillmanoy

    Joined:
    Jul 7, 2014
    Posts:
    120
    Do I have to include the demo scene and contents? If not then how can I do it?
     
  40. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    I think I've fixed the problem. The friction curve calculator had a top limit on its results, so the property that should prevent the vehicle from sliding at slopes (staticFrictionMax) was using an effective limit of 2500. I've noticed that setting staticFrictionMax to 3500 and removing the terrain detection seems to address the issue.

    Pull the latest changes from the repository, or contact me by email if you don't have access to it.

    The problem is at PhysX and WheelCollider level. You could try setting the vehicle to real values and adjust springs, dampers, and friction curves accordingly. You may find settings PhysX are happy with.

    Same as above. Vehicle physics in Unity doesn't seem to work fine with tiny values.

    The package iRDS seamlessly integrates with Edy's Vehicle Physics.

    The method SendInput in CarMain reads the values from the standard Input class. You can rewrite this function for reading the input values from the device of your choice.
     
  41. NorthernVisionStudio

    NorthernVisionStudio

    Joined:
    Oct 18, 2013
    Posts:
    60
    Hi Edy, Thanks for the great tool. So, I'm wondering about double a-arm suspension. When the wheel goes up and down, either compressed or hanging, it should travel in an arc (looking towards the front of the car). I haven't seen this effect in any of your videos. All I have seen is the wheel traveling up and down relative to body space. I will be needing this for our current project and I was hoping it was in the Unity5 version. Please tell me your thoughts on this. Feliz ano nuevo!
     
  42. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Hi! The actual movement follows the exact path of the WheelCollider's suspension. You could make the visual wheel mesh to move in the way you want, and it would be rather easy to visually simulate that kind of suspension. My system reports the actual state of the WheelCollider's suspension (compressed-uncompressed). This could be translated into a visual wheel movement like you described. There would be no changes at the physics behavior though.

    I might add this feature to the upcoming Vehicle Physics Pro.
     
  43. vencl0vs

    vencl0vs

    Joined:
    Feb 20, 2013
    Posts:
    9
    Hi Edy,

    Will it be possible to use new Vehicle Physics Pro for side scrolling 2.5D games, like Motocross Nitro http://www.miniclip.com/games/motocross-nitro/en/#t-sd ?

    And will it be possible to use for bikes simulation in 3D space for motocross/superbike types of games? I mean for vehicles with 2 wheels?

    Thanks!
     
  44. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Sure. The easiest way is to enable the rigidbody constraints to avoid rotation in the Y axis and movement on the Z or X axis (depending on the axis you're using for movement).

    An easy way for simulating bikes is tweaking the standard four-wheeled vehicle by placing the left-right wheels very close together and using only one visual wheel per axle. Also, the center of mass should be lowered below the ground.

    I plan to develop proper bike simulation as add-on for my upcoming package Vehicle Physics Pro.

    The absolutely reliable method is to make the rigidbody kinematic (rigidbody.isKinematic = true), then place/rotate the vehicle with MovePosition and MoveRotation. Ensure that isKinematic is true for at least one physic frame.

    The direct but less reliable method is resetting its values in a FixedUpdate frame like this:
    Code (CSharp):
    1. Vector3 eulerAngles = transform.localEulerAngles;
    2. rigidbody.MoveRotation(Quaternion.Euler(0, eulerAngles.y, 0));
    3. rigidbody.MovePosition(rigidbody.position + Vector3.up * 1.6f);
    4.  
    5. rigidbody.velocity = Vector3.zero;
    6. rigidbody.angularVelocity = Vector3.zero;
    Set the initial position and orientation in the MovePosition and MoveRotation parameters. In the avobe example I'm just conserving the actual orientation and seeting a position 1.6m above the actual position.

    Note that this method is not absolutely reliable: if the WheelColliders were modifying their forces in the previous frame, then these forces will be carried over to the frame where you have reset the vehicle's data. In other words, the vehicle might be moved/rotated in some amount after resetting it with the above method.
     
  45. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Hi, Im tempted to buy this as im after a car system that offers visual damage, but does anyone know if you replace the visual mesh with one of your own does the "visual damage" still get taken care of with this plugin?

    Thanks
     
  46. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    The damage script modifies the meshes on impacts. When replacing the visual mesh you must simply care that this script is aware of the new mesh, so the damage is applied to it as well.
     
  47. Mosy

    Mosy

    Joined:
    Aug 13, 2014
    Posts:
    24
    Edy thanks for all your work on this asset, it has truly made my current game much faster. In my game a couple of my trucks need a third axel, and I would really like to make those extra wheels animate just like the other 2 do, so I tried to make the extra wheels do nothing but the WheelVisual stuff, but those trucks keep tilting to the side when they aren't moving, and once they get far enough the wheels fly off the truck which is obviously a problem. Any ideas how I can make this work better?

    *EDIT*
    So far what I have been able to do was freeze the position of the trucks in the Y axis, and freeze the rotations of the trucks in the X and Z axes which prevents the trucks from tilting over, losing the wheels and then tumbling around the scene. However my extra axel wheels are not animating even though I added a DoWheelVisuals for them.
     
    Last edited: Jan 16, 2015
  48. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Mosy please email me to edytado@gmail.com so I could look at your case (include your invoice number).
     
  49. PatrickKa

    PatrickKa

    Joined:
    Apr 30, 2014
    Posts:
    245
    Hey, I want to use CarDamage in my mobile application. It actually works but I still notice some stuttering on collisions. Is there something that I could do to reduce the problem? Like change some parameters to make it less performance intensive?

    Would really appreciate some help. :)
     
  50. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365
    is their a csharp version?