Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  6. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Edy's Vehicle Physics - official thread

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

  1. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Hi there,

    I'm starting this thread on Edy's Vehicle Physics so you could post any questions, doubts or issues on the package.

    [​IMG]

    Edy’s Vehicle Physics is a set of scripts for developing fun and realistic vehicles in your game with Unity 3D. It’s based on the Unity’s standard WheelCollider component, which provides a much better performance and accuracy than Raycast-based vehicle physics.

    Importing and setting up the package

    Import the package normally into any project. A folder EVP will be created for all the imported scripts and assets.
     
    Last edited: Feb 2, 2016
  2. namoricoo

    namoricoo

    Joined:
    Apr 14, 2011
    Posts:
    534
    I downloaded the November update and the gray car drives to the left when I push the up arrow. The truck will drive straight. The wheel colliders are still hard to setup. Aside from that everything else is good.
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Note that the wheels can become misaligned as for the impacts, including hard contacts with the kerbs. Press shift-R to ensure that all damage is repaired and the wheels are realigned.
     
  4. Strangelite

    Strangelite

    Joined:
    Nov 19, 2010
    Posts:
    22
    Hi Edy,

    great news that you've added sound, but I can't get it to work (the live demo won't run on my machine even though I'm sure I've installed the 3.5 web player) - is this version going to be released when 3.5 is officially released?

    Also, I can't download V42.zip from your repository as it's claiming an End of File error. (possibly dodgy upload?) I've redownloaded it several times and it's not worked.

    Keep up the great work
     
  5. Balint3DDesign

    Balint3DDesign

    Joined:
    Apr 6, 2011
    Posts:
    110
    Hi!
    The new version of the live demo its awesome ,and the sounds are great .Keep up the good work.
    ps : I wrote a PM for you edy please read it.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    19,676
    Great work as always Edy. Btw for those using macs, many do not have page up and down ;)
     
  7. jeffmorris

    jeffmorris

    Joined:
    Nov 26, 2009
    Posts:
    144
    I created a copy of the project, removed the city from the project, and added my own "city". Because I have the free version of Unity 3D, I can't use the RenderToTexture command. I modified the bus mirror cameras and commented out any script lines that refer to the bus mirrors. I still get "Null Reference" errors. I want to use the mirror cameras with other vehicles. How can I do this? A suggestion: Have the driver put the automatic transmission in "Reverse", "Neutral", and "Drive".
     
  8. jeffmorris

    jeffmorris

    Joined:
    Nov 26, 2009
    Posts:
    144
    I found out that I forgot to add the Skidmarks and StartTestPoint assets to my "city". That got rid of the "Null Reference" errors." What about the mirrors?
     
  9. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Maybe you can try re-installing the beta? Keep internet browsers closed during installation.

    Yes, this version will be merged into the master branch (GIT) and updated at the Asset Store once the final Unity 3D 3.5 is released.

    You are right, the V42.zip file was incomplete. Fixed!
    Thanks!
     
  10. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Yes, but you have one of those intuitive and easy to remember combos of ctrl-alt-cmd-shift with up/down keys that emulate the page up and page down :p

    Beware of trying to find the right combo while you are writing a lot of text in a web form or you may hit the combo for "Back" instead and loose everything you had written... xD
     
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    19,676
    lol exactly! exactly. I was wondering why I was watching some form of full screen movie theatre last time I tried.
     
  12. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Mirrors are automatically disabled when the references are not filled. Note how this is verified at the function UpdateMirrors in the CameraControl script.

    The prefab Main at EdyVehiclePhysics\Prefabs contains the necessary objects for implementing the mirrors (GUITextures). In order for them to work properly you must first ensure that the CameraControl script at the MainCamera object contains the references for the mirror GUITextures that are children of Main (MirrorLeftTex, MirrorRightTex, MirrorRearTex):

    $vehiclephysics-setupmirrors.png

    Then, for each vehicle with mirrors you must:

    1. Create and place the cameras that will actually provide the picture for each mirror of the vehicle. See the example cameras at the bus (Bus > MirrorCameras at the Hierarchy).
    2. Reference those cameras at the CarCameras component of the vehicle. There you can find the references for placing the cameras for left, right and rear mirrors. Again, see the example at the Bus, CarCameras component at the root GameObject.

    Ready. Use the ShowMirrors flag at the CameraControl component from MainCamera (see pic) to globally enable or disable the mirrors.
     
  13. jeffmorris

    jeffmorris

    Joined:
    Nov 26, 2009
    Posts:
    144
    Edy, Do you use RenderToTexture? I think that free version of Unity 3.4 or 3.5 doesn't have it.
     
  14. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Ooops... you're right. The cameras providing the picture for the mirrors are rendering to a texture, which is displayed later as GUITexture. This requires Unity Pro.

    You still could do a kind of mirror by using a plain camera attached to a vehicle and setting the camera's normalize viewport rect to appear as a mirror. However you cannot flip the image horizontally with Unity Free.
     
  15. jeffmorris

    jeffmorris

    Joined:
    Nov 26, 2009
    Posts:
    144
    How do I enable and disable the mirror cameras belonging to the car, truck, and bus when I press the [Page Up] and [Page Down] keys to select the vehicles? I made copies of MirrorCameras and renamed the copies bus-MirrorCameras, car-MirrorCameras, and truck-MirrorCameras. I did the same thing with MirrorL-Cam and MirrorR-Cam.

    bus-MirrorCameras
    bus-MirrorL-Cam
    bus-MirrorR-Cam

    car-MirrorCameras
    car-MirrorL-Cam
    car-MirrorR-Cam
     
  16. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,222
    Hey Edy,

    Do you not have a C# version of this project?
     
  17. xXCATF1SH

    xXCATF1SH

    Joined:
    Jan 24, 2012
    Posts:
    4
    Hey Edy,

    How would you recommend altering forwardWheelFriction | rearWheelFriction values when the player drives through a trigger capsule?

    (Trying to create different types of terrains, ie. slippery ice)

    Cheers and Thank You!
     
  18. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    19,676
    Hi Edy, I have lost access to the project and I'm wondering if you would answer my email from hippocoder please :) I tried the codaset link from the email from a while ago to redownload but codaset seems down?

    Meanwhile I will use the old version as I wait patiently :)
     
  19. UnleadedGames

    UnleadedGames

    Joined:
    Feb 17, 2008
    Posts:
    242
    Same issue as hippocoder, emailed you my Paypal receipt along with a PM to explain whats going on :)
     
  20. vortexilation

    vortexilation

    Joined:
    Sep 25, 2009
    Posts:
    259
    P.M him, a while ago he was moved out the repo into his own server.
     
  21. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Hi guys, sorry for the delay. I've been insanely busy these past days working on a different project for a third party. It's now complete, so I'm catching up with the emails and PMs.

    When Codaset closed services I moved the repository and documentation to www.repositoryhosting.com. The URL is http://projects.edy.es
     
  22. omarzonex

    omarzonex

    Joined:
    Jan 16, 2012
    Posts:
    150
  23. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    19,676
    Nice caps man. Do you expect to get far in development by ranting like that?
     
  24. malyna

    malyna

    Joined:
    Jul 9, 2010
    Posts:
    105
    Hi Edy,

    I've downloaded the project through GIT but it is the one without sound or gears display (D-N-R instead). Should it be the one from the latest live demo ? Maybe i'am doing sth wrong ?

    Thx for reply. Cya.
     
  25. Duskling

    Duskling

    Joined:
    Mar 15, 2011
    Posts:
    1,197
    I purchased the product, But there is nothing in the documentation that walks me through how to set this up on my own car model. I have tried it but I'm just getting all sorts of null reference errors.
     
  26. Harsh

    Harsh

    Joined:
    Jan 9, 2012
    Posts:
    8
    Hello Edy,
    I have bought your toolkit from asset store. I am facing serious problems in implementing the vehicle physics to my own designed car. I have applied all the scripts properly as it is shown in inspector, but my cars are not running properly, the issues I am facing are :
    1. Not smooth driving
    2. At higher speeds, it doesnt take turns.


    I will highly appreciate if someone can write steps in detail of how to implement edy's vehicle physics in own custoomised car.
     
  27. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    19,676
  28. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    You must check out the branch 3.5beta:

    $ git checkout 3.5beta

    I strongly recommend you to use any of the available vehicle prefabs as starting point. You can then change the 3D model and adjust wheel positions, center of mass, etc. and fine tune the settings for targeting the desired gameplay. The result will be the same you would reach by starting from scratch, but this way you'll have a working vehicle since the beginning.

    The main settings that define the vehicle's handling and behavior are:

    1- Suspension settings at the WheelColliders. They must be configured normally at the standard WheelCollider components.
    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarWheel

    2- The friction parameters at CarControl. Despite they are well documented, the best way to learn to use them is to take one of the available vehicle prefabs, then change each setting at once and observing the result.
    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarControl

    Also, I recommend you to use the curve display provided by the cartelemetry.js script (B, then shift-B at the Demo) to see what's happening with the tires, and ensuring that the changes in the settings have the desired effect.
     
  29. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    You must reference each vehicle's cameras at their CarCameras.js script. When selecting a different vehicle with page up-down, if any mirror camera is assigned at its CarCameras script, then it will be used for feeding the corresponding GUITexture as mirror.

    No, sorry. However I'm aware of projects written in C# that successfully used the Vehicle Physics by moving the folder into one of the Unity's privileged folders (i.e. Standard Assets).

    Multiply the grip and drift values with the friction factor. For instance, if grip=1000 and drift=500, given a friction factor of 0.2 (for ice) it would result in grip=200 and drift=100. Note that TC (traction control) will avoid the tire to slip longitudinally, which may result in a "loss of power" feeling. You may consider disabling TC as well.

    Also note that the wheel component actually reads the dynamicFriction value from the physic material underneath, and applies both friction factor and rolling force.
     
  30. Strangelite

    Strangelite

    Joined:
    Nov 19, 2010
    Posts:
    22
    Hey Edy, Great work (and some interesting advice about friction surfaces) as always...

    Do you have any plans to put in manual gear shifts? (seems like you're going that way with 3.5) - would love to be able to manually change the gears (I've actually already put in my own sound system with a gearing ratio for the sounds pitch - but couldn't work out how to tie it all into the drive system) - I'd absolutely LOVE it to be an option (like TC and ESP is currently)

    Also, could you consider putting an example of reduced friction into the demo? (like an "ice patch" or something) so we could see how you'd implement it? (or is it simply a case of altering the friction properties in the physics material?)

    I also can't help feeling in an ideal world there'd be a wrapper class which basically has very simple settings like "acceleration" which then goes and alters the various variables the would affect the acceleration. I might have to script that myself ;)

    Keep up the good work though! :D
     
  31. WillModelForFood

    WillModelForFood

    Joined:
    Dec 5, 2011
    Posts:
    143
    Great! Now all I need is to find a networking programmer to convert this project into multiplayer, possibly uLink? Or something else. If anyone can do it please PM me with a reasonable rate! Awesome updates!
     
  32. Strangelite

    Strangelite

    Joined:
    Nov 19, 2010
    Posts:
    22
    I've already networked this engine, It's pretty straight forward to be honest.

    the only really tricky bit is you have to make the cars instantiatable objects... (which means handling the controller code so that it "points" to the spawned cars.) Then just having client cars with enough network views on it.

    www.stuntcaronline.com shows off a prototype of the networking (obviously you'll need 2 PC's to see it properly!)

    Note: I'm a pretty rubbish programmer, so if I can do it, anyone can! :)
     
  33. Duskling

    Duskling

    Joined:
    Mar 15, 2011
    Posts:
    1,197
    How would I make the car accelerate faster?
     
  34. nogue2k

    nogue2k

    Joined:
    Feb 28, 2012
    Posts:
    3
    Can anyone help me with a problem im having?

    you can see it in this video. -> http://www.youtube.com/watch?v=-pCef16i-FM&feature=youtu.be

    I need to make a farm Tractor so i made the back Wheels turn too, half the angle from the front ones.

    When i turn, one of the back wheels go crazy and starts rotating more than it should. It only happens if speed is higher than 20miles and only one of the wheels.

    any help would be apreciated.

    Thank you.
     
  35. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Manual shifts will be available at the next major version (almost a totally new project). In current version it would require ugly tweaks for combining the revs with the air drag (as the speed must be limited using air drag).

    Sand and grass are actually samples of reduced friction and increased roll resistance (so the vehicle won't reach same speeds than over asphalt). Find the physics materials under "World\Physic Materials". Each wheel (CarWheel.js) looks up the physic material of the ground underneath, and reads its Dynamic Friction value. This value multiplies the grip and drift values, so the friction is reduced. Also, a proportional drag force is applied according to that value.

    About acceleration: note that the parameter motorPerformancePeak at CarControl is actually something like that. It allows you to specify the acceleration of the vehicle in ideal conditions. Note that more acceleration means more force applied at the wheels, so the vehicle may need additional tweaks (i.e. the top speed depends on this value).

    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarControl

    Read the above paragraph about acceleration. The motorPerformancePeak parameter at CarControl defines the acceleration of the vehicle.

    I strongly recommend you to add the CarTelemetry script to your project. This allows you to see what's exactly happening at each wheel, and fine tune the parameters accordingly. The documentation sometimes refer to the telemetry values.

    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarTelemetry

    [​IMG]

    You can see the explanation of each parameter here:
    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarTelemetry
     
    Last edited: Mar 13, 2012
  36. MHG12

    MHG12

    Joined:
    Mar 21, 2012
    Posts:
    6
    Hi Edy!
    Thanks a lot for your vehicle physics,nice work!
    I've got your package and test the sample " The City ".
    I want to import my own car and own city. I've perused the "Sport Coupe" perfab and mesh model .FBX file in 3ds max.
    I've refined my own car same the sport coupe models and mesh model's name were same: "SportCoupe_SteeringWheel , SCBrake_RL , SCTire_FR ,.... " 10 objects in FBX mesh file.
    When I replaced FBX file with " sportCoupe.fbx " and opened the project,I got wrong! :confused:
    Here is a picture of project :

    $edy-mesh.jpg


    Please make some video tutorials that show how we can add our own vehicles in project and how about city models and...
    How to add correctly scripts and setting up our vehicles,with your wonderful package ?
    I read your some documentations but I can't add my vehicle rightly!
    Please make some video trainings helpful ! ;)
    Thanks a lot
    Have a nice time !
     
  37. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    That problem is caused by the scale-rotation issues when exporting to FBX from Max, and then re-importing from Unity. Also, scales are applied different in Unity and Max.

    Check out the pickup trucks (red or blue) at the demo for realizing how a scaled model can be used: the scale should be applied ONLY at the main GameObject. Everything else must have a scale of 1,1,1 for ensuring coherency.

    I plan to record a couple of training videos on how to properly setu up a vehicle for Unity and Vehicle Physics.
    Hope this helps!
     
  38. artonator

    artonator

    Joined:
    Sep 12, 2009
    Posts:
    67
    Hi,

    I tried your demo few times and I like what I see there, I was wondering what is a work flow to impliment your system on my own car, Say I have a buggy car or monster truck?


    thank you,
     
  39. MHG12

    MHG12

    Joined:
    Mar 21, 2012
    Posts:
    6
    Yes, it's the best way to help us!
    Your video tutorials will helpful for someone that is not very professional user.
    Thanks a lot.
    I'll looking for your training videos.
     
  40. FIREDANCEXS

    FIREDANCEXS

    Joined:
    Jan 30, 2012
    Posts:
    17
    Do you have any links/advice on how I should go about making the wheels spin like you have with "TC" disabled? I cant work out what to do to make this effect in a game im working on as I learn Unity. I tried changing the stiffness factors of the wheel colliders - the wheels spin, but the car just goes round in circles on itself :/ Thanks
     
  41. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    The fastest way is to take one of the available vehicles, then change its mesh objects and wheel locations. Ensure not to apply any scales or rotations other than in the final mesh gameobjects. Check out the available vehicles to learn where and how the wheel meshes are placed.

    In Edy's Vehicle Physics is easy, you just have to manage two properties (motorMax and sidewaysDriftFriction, then disable TC to see the effect). I'm afraid that due to the in-famous WheelCollider bug this cannot be realized using plain WheelColliders without dynamically adjusting their friction curve parameters (which is what my script does for you).
     
  42. fjunior

    fjunior

    Joined:
    Apr 1, 2012
    Posts:
    1
    Hey Edy, Congrats for the great work.

    Any estimated date to release this next version?

    Thanks,

     
  43. gerlonx

    gerlonx

    Joined:
    Aug 5, 2010
    Posts:
    12
    Hi,

    How to achieve switching gear Forward -> Reverse and vice versa smoothly.
    I mean, I've tried uncheck the "Reverse requires Stop" but still I have to Handbrake first for switching gear.

    Thanks in advance
     
  44. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Ok, there's a mistake at the code. You must disable that option at the CarMain script, at the MAIN gameObject. The option is also at the CarControl script, but it's ineffective here. I'm removing it, so use the CarMain's.

    Not yet, still at the R&D phase (looking really promising though).
     
  45. Mr Turnip Head

    Mr Turnip Head

    Joined:
    Feb 9, 2010
    Posts:
    34
    I can't get the skid marks to work. I have added the Skidmarks prefab into the scene but they don't seem to be working. Any obvious steps I may be missing?

    UPDATE: I can now get the smoke to work if I remove the physics material from the terrain, but the skid marks are still missing.
     
    Last edited: Apr 3, 2012
  46. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Ahhh ok! Does the terrain (or any of its ancestors) has a rigidbody component? If so, the script assumes that the object can be moved, so it doesn't create the skidmarks over it.

    Actual rules for smoke / skidmarks are:
    - If the collider has a rigidbody attached, assumes moveable object. Creates smoke but not skidmarks.
    - If the collider has a physic material, assumes offroad terrain. Don't generate smoke nor skidmarks

    Skidmarks and smoke are both generated over colliders that don't have physic material and with no rigidbody attached.
     
  47. vrgz

    vrgz

    Joined:
    Apr 20, 2011
    Posts:
    29
    Hey Edy, thanks for the great work.

    can this work in ios?
     
  48. lzt120

    lzt120

    Joined:
    Apr 13, 2010
    Posts:
    90
    Hey Edy,

    After instantiate the Vehicles prefabs, I got error message from console:WheelCollider requires an attached Rigidbody to function. And how can I fixed it? And when I use SetActiveRecursively function it will also have the error message as above.

    Would you have your system to be in C# script for easy access from C# ?
     
  49. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hi Edy.

    I've one question about the weight feeling of the cars.

    My issues is that the cars "take of" too easily IMO, a simple bump at medium speed will desestabilize the car easily, and the ramp jump feels a bit lunar gravity affected.

    I tried to increase the weight significantly but as the driving yes does feel better, the jumps keep on being looong.

    Any way to make the car perform more "realisticly" i this aspect??

    Regards

    Pablo.
     
  50. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    845
    Yes. I haven't tested it personally but I'm aware of people using the scripts on iOS successfully.

    Can you provide a small testing script that shows the error? Please pm me for instructions on sending it.

    You can move the EdyVehiclePhysics folder into any of the privileged folders, i.e. Plugins or Standard Assets. You can then access all the components and methods in the same way as if it were C#.

    Gravity is acceleration, so it will be the same no matter the weight of your object. You can mimic the behavior of the gravity by setting rigidbody.useGravity = false, then adding this line to the FixedUpdate method:

    Code (csharp):
    1. rigidbody.AddForce(Physics.gravity * rigidbody.mass);
    So if you want, for instance, duplicate the gravity you can use:

    Code (csharp):
    1. rigidbody.AddForce(Physics.gravity * rigidbody.mass * 2.0);
    Note that the extra force will compress the suspension of the vehicle according to the new gravity, so you should multiply the spring values of the WheelColliders accordingly. I haven't tested this, but I guess that you should multiply the spring value by the same factor used for multiplying the gravity.