Search Unity

Edy's Vehicle Physics - official thread

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

  1. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,122
    You can either rotate all the pivots in 3dsmax to the correct axis orientation, or in Unity create empty game objects and make the car a child of the empty game object and rotate the car to correct orientation.

    Here is a video I did showing 2nd methods in UnityFS, while a different package is the exact same issue.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    As I've understood, the issue is "2- To prevent long duration jumps". Your actual solution (increasing gravity) involves a rather complex dependency on the other settings.

    I think there's a better solution: adding an extra acceleration to the vehicles when they're in the air only (long jumps). You can detect that by looking at certain conditions, for example:

    - At least 2-3 wheels (out of 4) are lifted. (check out VehicleController.wheelData[n].grounded)
    - Speed is greater than a minimum (read it at VehicleController.cachedRigidbody.velocity.magnitude)

    While the conditions are met you can add an extra acceleration downwards:

    Code (csharp):
    1. VehicleController.cachedRigidbody.AddForce(Vector3.down * extraAcceleration, ForceMode.Acceleration);
    This solution would apply an increased gravity force only when the vehicle is in the air. So once you
    have configured it properly, you won't need to modify the settings for the long jumps. And the
    amount of extra gravity acceleration is easily customizable.
     
    hopeful likes this.
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Beta 4 is already in the review queue. New features:

    - VehicleAudio component now includes lots of audio effects and features. Note: Requires re-configuring the engine audio.
    - Tire marks, skid marks, smoke, dust.
    - Custom shader for particle effects featuring configurable particle shadows.
    - Multiple ground materials supported with grip & drag & tire effects per-material.
    - Telemetry show/hide key (Y) and different telemetry modes (shift-Y).
    - Damage levels exposed in the VehicleDamage component.
    - Fixed compilation for Windows Store Universal 8.1 (thanks to Denis Osipov)

    The beta 4 Demo is already live:
    http://www.edy.es/dev/vehicle-physics/demo

    Use IE, Safari or Firefox. Chrome and Chromium-based browsers do not support the Unity plugin anymore.


    It depends on each specific configuration. The values you should look at are:
    • Longitudinal position of the center of mass. This has great influence in the handling.
    • Max Drive Force. There must be enough force for allowing sustanied burnout.
    • Max Drive Slip: This is probably the most important, as it defines how much the wheel will slip when being burned out. More slip will make the vehicle to slide sideways easier, but too much slip may make easier to loose the control.
    • DriveForceToMaxSlip: this is the excess of force that makes the former drive slip value to go to the maximum. Ensure to understand the relationship among Force - Slip. It's explained at the docs for this parameter.
    Other related parameters are:
    • TC Ratio: Traction Control (TC) limits the amount of slip. If enabled and set to 1, it voids the configured slip values. Useful for enabling/disabling the drift mode.
    • Max Steer Angle: There should be enough steering angle available for allowing the vehicle to drift sideways.
    • ESP Ratio: Esp limits the steering angle with speed.
    The vehicle controller in the future release 5.1 will have much easier parameters for configuring the vehicle's behavior.
     
    phimo and gurayg like this.
  4. phimo

    phimo

    Joined:
    Aug 7, 2012
    Posts:
    9
    It does look fantastic! :) Did not expect that much to change. Very nice release!


    Thanks for your hints. I will try to modify these values to get the right behaviour. :)

    I'm looking forward to 5.1 :)
     
  5. quesadillas

    quesadillas

    Joined:
    May 1, 2015
    Posts:
    23
    Hi Edy!
    So I've been using two scripts from this site (http://visionpunk.vanillaforums.com...dys-vehicle-physics-ufps-how-can-this-be-done) in order to be able to switch between UFPS and your vehicle package. I've tweaked it here and there, but essentially I've gotten it to work! However, I'm having some trouble.

    So, at start-up, I have the car's camera and its VehicleController script disabled. Once the player presses a button near the car, it switches over by disabling pretty much everything concerning the player, and enabling the two components I mentioned. The player can then use the car's controls just fine. However, once the player gets back out of the car, the car has some issues. Suddenly it's surprisingly light! I can push it around, even though the RigidBody still says its mass is at 13500! None of the Rigidbody properties have changed, and I can't push the cars around like this if I don't try driving in them first.

    I took some video of it in case my explanation didn't make sense; I used the bus because it's easier to see the difference.

    I know it doesn't relate 100% to your package because I'm using a custom script but can you think of anything in your package that changes the state of the car in some way that could affect its physics properties?

    I also have another question that could be related to this. So it seems that the cars automatically have some AI enabled at start-up; I couldn't find any sort of switch to turn off this AI without having to disable the VehicleController script entirely. Is there another way to do this or is this the best way?

    Thank you!
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @quesadillas You shouldn't disable the VehicleController component! It provides the actual vehicle physics and calculates the tire forces. When the controller is disabled there are no tire forces applied, so the vehicle slides like on ice.

    Instead, disable the component VehicleStandardInput (so your input doesn't reach the vehicle) and set VehicleController.brakeInput to 1 for keeping it stopped. This will make the parked vehicle to continue behaving like a vehicle (i.e. when pushed by other vehicles). The next version will include a new parameter "parked" for convenience on these kind of situations.

    Cars do not have any AI enabled. In the demo scene, the green pickup truck has the component VehicleRandomInput (instead of VehicleStandardInput), so it moves randomly. This is an example on how to implement / adapt an AI system in EVP.
     
  7. quesadillas

    quesadillas

    Joined:
    May 1, 2015
    Posts:
    23
    Hooooly cow, I feel dumb, I should not have been disabling it. It's even in your documentation! Ah well, I'm glad I asked, it was a good wake-up call.
    I'm still having a similar issue after following your suggestions, but I think it's a mistake in my own script dealing with where I move the character and how I leave the bus, so I'll be looking at that instead.

    Yeah I was just calling the random movement "AI" but I guess it's not exactly that.
    Thanks so much!
     
    Last edited: Aug 18, 2015
  8. Cool_Flow

    Cool_Flow

    Joined:
    Apr 14, 2013
    Posts:
    21
    Hey Edy, love the vehicle physics. I finally decided you use your asset in a new game I'm designing, but I'm having an issue. I looked through the entire forum before I posted.

    Just for testing purposes I placed one of your prefab vehicles in my scene. As soon as I hit play, the vehicle hits the ground and gets shot in a random direction spinning and flipping like crazy. I haven't touched any settings, but I wanted to use your test vehicles as place holders until I get my own created.

    I am using Edy's Vehicle Physics 4.4, I newest you just released.
    and Unity 5.1.0f3

    As soon as I hit play I get this warning from your CarControl.js script. "SetUseConeFriction has no effect. Cone friction is no longer supported, see setFrictionModel instead UnityEngine.Rigidbody:set_useConeFriction(Boolean)"
     
  9. mkgm

    mkgm

    Joined:
    Apr 10, 2015
    Posts:
    134
    @Cool_Flow

    you must use EVP 5.0.4 with Unity 5+.
    Download EVP 5.0.4 using Unity version 5.

    Let me know if that works.
     
  10. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @Cool_Flow: As @mkgm pointed out, you must download EVP using the Asset Store window in Unity 5. Latest version of EVP is 5.0b4.
     
  11. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    354
    Hi Edy,

    I'm trying with both Unity 5.0.2p4 and 5.1.0f3 versions but it only downloads the EVP version 4.4.
     
  12. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    Hello Edy.. great work with the beta updates.. loving it!!!

    Oh by the way can you recommend any ai solutions that work with your asset?
     
  13. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Oh... This is strange. The package has been submitted using Unity 5.1.1. Maybe the Asset Store is giving you EVP4 because it thinks that your version (5.1.0) is behind the actual package version (5.1.1), so it "reverts" to the "latest supposedly compatible version"?

    Can you try with Unity 5.1.1? If I can confirm this behavior, then I think I should re-submit EVP5 with Unity 5.0.0...

    Thank you!
    The AI packages developed by Jose Garrido are fully compatible with EVP .)
     
  14. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    This is what has been happening with all the assets in the store. It looks like this is the new normal.
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Not a bad thing to be on the latest minor version of Unity for say 99% of people...
     
  16. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    And another new one is coming out in about 3 weeks ...
     
  17. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Oh! ok, I'm downloading Unity 5.0.0 now. Will resubmit the package with it.
     
  18. Cool_Flow

    Cool_Flow

    Joined:
    Apr 14, 2013
    Posts:
    21
    Same here Edy. No matter how many times I download, it always sticks with v4.4. Doesn't seem like it wants to update it to your newest version.
     
  19. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Latest version seems to be delivered from Unity 5.1.1 or later only. I'm re-uploading the package right now using Unity 5.0.0, so it will work from any Unity 5 version.
     
  20. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    354
    I tried with 5.1.2p3 now, it downloaded 5.0 beta 4, so that's the case obviously.
    Interesting publishing choice by Unity
     
  21. Cool_Flow

    Cool_Flow

    Joined:
    Apr 14, 2013
    Posts:
    21
    Version 5.1.0f3 doesn't update, so I installed 5.1.2f1 of Unity and it worked right away.

    Very weird choice for Unity to do that, but at least it's fixed now. :) Thanks Edy.
     
  22. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You guys really should keep up to date with Unity :p
     
  23. Cool_Flow

    Cool_Flow

    Joined:
    Apr 14, 2013
    Posts:
    21
    I would but pressing Check for updates in Unity said it was up-to-date even though it wasn't. :) So leave it to Unity to have that not work right either. lol
     
  24. Viza

    Viza

    Joined:
    Aug 25, 2013
    Posts:
    3
    Hi Edy,

    I tried to build a level with horizontally moving platforms (think moving trains, or conveyor belts, or just platformer style moving boxes), but it seems that the car don't react to it at all - just stands there like it's stands on solid, non-moving ground, completely ignoring the effect of any horizontal movement, and the platform slides around under it freely.

    In one of the original videos of the package, a pickup drives onto a bus, and later as the bus moves, the pickup moves with it, so I suppose it is possible to do, but I just can't figure out how... :-/

    I just placed a cube in the scene and gave it an animation. I tried to give it a kinematic rigidbody too. I tried to animate an empty kinematic gameobject, and connect the platform to it with a fixed joint (to try to keep the moving platform non-kinematic).

    So, what am I missing?
     
  25. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Heh, they stagger those notifications until much later. Keeping an eye on forums or the download page is best!
     
  26. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @Viza the moving elements must be kinematic rigidbodies moved using rigidbody.MovePosition and rigidbody.MoveRotation.
     
  27. Viza

    Viza

    Joined:
    Aug 25, 2013
    Posts:
    3
    @Edy Way better - the platform now moves the vehicle, but still not perfect: it seems that I can't drive to the opposite direction of the platform's movement. If the platform moves to the x+ direction, it is not possible to drive on it to x- direction once I stop.

    It's not a friction thing: you can hear the engine is just idling, not even tries to move.
    There is a small dashed (if thats the correct word) skid sound playing.

    It only happens if I stop on the moving platform, and try to move again - I can drive around without problems if I move constantly. And I can move after stopping too, but only if I start to move in the same direction as the moving platform.

    Any ideas why this could happen?
     
  28. Viza

    Viza

    Joined:
    Aug 25, 2013
    Posts:
    3
    OK, the problem is that the car thinks the moving platform's speed is it's actual speed, and so the VehicleStandardController does not allow to move in the opposite direction since the platform's speed is bigger than the allowed default threshold in that script.
    Either turning off the continuousForwardAndReverse function and manually changing the forward reverse direction, or increasing the minSpeed fixes the problem.
    Kinda hacky solution, but detecting the ground's speed under the car seems to be bigger task for this edge case than watching for the platforms to not exciding the new threshold.
     
  29. Cool_Flow

    Cool_Flow

    Joined:
    Apr 14, 2013
    Posts:
    21
    Good to know. Thanks. :)
     
  30. ZiadJ

    ZiadJ

    Joined:
    Sep 3, 2011
    Posts:
    62
    EVP would appeal to me if it exposes the torque affecting the wheels along the Y axis. Is that's not the case then will this be possible in the not so distant future?
     
  31. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    EVP is designed for ease of use, so it implements a simplified wheel model based on forces and angular velocities only, no torques. Vehicle's behavior and reactions are much easier to configure this way.

    I'm developing another vehicle physics package, Vehicle Physics Pro (VPP). This package implements a realistic wheel and tire simulation model with all torques and forces being correctly computed and combined: drive torque, brake torque, friction-induced torque, and reaction torque.

    VPP is actually in pre-alpha stage, but I'm offering Early Access with the professional license. See vehiclephysics.com for more information.
     
    ZiadJ likes this.
  32. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Edy, I'm using the U4 version. The car RPMs aren't changing, they're constantly at my minimum 400 amount, is there a reason this would happen?
     
  33. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @carking1996 Most probably the value of CarAudio.transmissionRatio is too low, or even 0. The engine parameters are configured at CarAudio: wheel's spin rate are converted into RPMs using this ratio; then the engine sound and other effects are simulated with the resulting value.
     
  34. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    The ratio is 13.6, but the gears don't seem to be changing(stuck at 1) and the transmission RPM is 0.
     
  35. bdsowers

    bdsowers

    Joined:
    Oct 11, 2014
    Posts:
    14
    I'm wondering how I would tweak the handbrake behavior. Whenever I release the acceleration and hit the handbrake, I almost invariably end up out of control and turned around in an instant. I've tried fiddling with all the slip settings, but I can't seem to find values that make that behavior a little... subtler.

    Related: I'd like to be able to maintain forward momentum while slipping and then be able to regain control quickly (I suppose this is called drift?). I see above that there are some values to tweak, but it's unclear how to tweak them in real-time when your physics skills are lacking. :) It's also unclear whether this is an extension of handbrake behavior or whether I need a different approach entirely.

    Any help with these would be greatly appreciated.
     
  36. amorrow68

    amorrow68

    Joined:
    Aug 10, 2015
    Posts:
    8
    Hello, I just purchased this and was hoping for some setup tips. Im looking to have the truck perform like the drifting in this video:



    Basically id like a 4 wheel drift that carries the momentum around the corners.

    Thanks in advance!
     
  37. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Perhaps turn off traction control etc?
     
  38. amorrow68

    amorrow68

    Joined:
    Aug 10, 2015
    Posts:
    8
    Thanks tried that, the front end pushes and tough to get turned or break into a drift.
     
  39. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Edy, I'm still having this issue.
     
  40. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Se the Handbrake mode to "Slip" and find a good Max Handbrake Slip value (m/s) that works as you expect.
     
  41. adriansotov

    adriansotov

    Joined:
    Jul 14, 2015
    Posts:
    16
    Hi, I'm new to the vehicle package. I just downloaded it and followed the youtube tutorial.

    For some reason the car only moves very slowly. If I increase the force tires go faster but the car still moves slowly. Any ideas what might be the problem?
     
  42. pinchmass

    pinchmass

    Joined:
    Jul 2, 2012
    Posts:
    156
    hi bit off topic but can anyone recommend a rag doll system to work with EVP (so I can run people over)

    in the nicest possible way.....
     
  43. Yubhaseni-J

    Yubhaseni-J

    Joined:
    Sep 11, 2015
    Posts:
    3
    Man How do Yu drift a car using Edys Physics 4
     
  44. Jeremy2300

    Jeremy2300

    Joined:
    Oct 23, 2013
    Posts:
    4
    I was curious, is there a simple way to introduce a tread system to Edy's?

    I'm using the plug-in in Unity 5 for my current trucks, but I'd like to have my excavators and bulldozers behave a bit differently.

    Mostly in terms of turning. Say I'm trying to turn left, I'd apply forward force to the right side and reverse (or none) force to the left.

    I have no problem writing this in myself, but I'm trying to keep the plug-in up to date and would like to keep my own maintenance as light as possible. So I thought I'd see if there was a simple solution to separate the left and right side inputs.
     
  45. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    I'm still in 4.x and quite happy. Nothing bakes like beast in the forever calculating unity 5.
     
  46. PhantomThom

    PhantomThom

    Joined:
    Nov 22, 2014
    Posts:
    6
    SO it seems when turning in Edys you cant accelerate, my speed just drops like its limited with turning. You should be able to gun the gas at low speeds while turning a tight circle to "burn out" or at least get acceleration. Instead, if I hold hard to the left and full throttle, the car just slows right down and drives at a snails pace in circle, no acceleration. Any ideas?
     
    Last edited: Sep 22, 2015
  47. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    I don't think so with EVP. It's designed for simple wheeled vehicles.

    In VPP it would be easy to simulate tracks by using two rows of wheels. The transmission could be setup so each row spins synchronously. Finally, each track could be driven by an independent motor. Thus, the behavior could be pretty accurate as each motor could drive its row forward or reverse at any time.

    Reduce the TC level (Traction Control). TC limits power for preventing the wheel to slip. When turning the wheels are typically slipping a bit, so TC limits power as it would increase slip. Reducing TC level allows part of the drive power to reach the wheels anyways.
     
  48. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    I'm having an issue with the car shaking all over the place. it's releated to the colider because if I change it's size then theres problems.

    But before the recent update this wasnt a problem. I could make the main colider thin and it wouldnt have an negative effect.

    I cant have a big box colider on my truck because I want to be able to put boxes in the back. so I have to have the main colider thin (Y). I hope that makes sense.

    Can you give me any tips here?
    also how does this system know which colider is the main colider?

    Thanks.
     
  49. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hello!

    I'm wondering if it's feasible or viable to use EVP for tank simulation. In this case, wheels rotate counter in order to turn and I'm not sure where this change could be made in a useful way ie moving and turning within EVP.
     
  50. PhantomThom

    PhantomThom

    Joined:
    Nov 22, 2014
    Posts:
    6
    Thanks for your reply Edy.

    One more for you, in the documentation you mention load as used in many calculations but I can't seem to find how load itself is calculated. Does is the mass of the rigidbody used in the calculation? Could you let us know how load is calculated? Thanks!