Search Unity

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:
    2,508
    Simply increase MaxDriveForce until the vehicle can climb those slopes. This will also increase the acceleration, so you might want to tweak the Force Curve Shape as well to a smaller value. I presume the type of curve used in GTA5 is like this:

    upload_2016-5-13_10-38-20.png

    In summary, it's a matter of adjusting max drive force, force curve shape and max speed forward (as tweaking the acceleration may affect the effective max speed as well).
     
    hippocoder likes this.
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Brilliant support, thanks Edy :)
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hi Edy,

    I'm finding it's a bit too twitchy. When my 80 kg mass player touches the car which is 1000kg, the car raises or hops like a little rabbit. That's really unusual - any idea what might be causing it? it seems hyper responsive to physics based character controllers (such as that from puppet master). I've asked a similar question over on partel's thread. Seems like they explode, it also breaks puppet master, as if you're applying powerful response forces or maybe puppet master is.

    The post on puppet master is here: http://forum.unity3d.com/threads/pu...ics-tool-released.358445/page-10#post-2634426

    edit: also happens with my own controller, and I have to make it really weak so it won't. I suspect it's related to whatever actions you take when the car collides... I need to control or switch that response off I think?



    Edit: One more observation: the suspension only "activates" or responds if there is a weight on the car or another physics interaction on it - it is flat with no suspension happening until it touches something be it a simple ball or a wall. Any idea why? otherwise it sits dead with no suspension force... Could this be a bug with newer 5.3.4+ builds? Also flat when driving (unless it touches something).

    I have a gravity of -28 for my game so things are snappy, but I notice it's similar behaviour with -10, just less visible - still there though.
     
    Last edited: May 14, 2016
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Wow, that's really strange! Can it be reproduced using the Demo scene and resources only?

    Let's say that you have the EVP demo scene, drop a character controller prefab on it (coming from the Standard Assets, from example), and the demo vehicles will explode at the slightest contact?

    The problem persists on these conditions, then please try it again but disable the VehicleController component before touching the vehicle. What happens then?
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I fixed the hopping - I believe it was because Enable Adaptive Force was checked with larger than normal gravity. I'm still able to push it around a bit too easily but it's bearable. I think really, I need to keep my masses very low for the character overall, in these circumstances.

    I can understand how -28 for gravity might throw all the math out the window a little...

    I don't think it's your fault :)
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Thanks for the update!

    The wheel contacts should be in sleep mode at rest unless contacted with a relative velocity greater than 4.0 m/s. For instance, a vehicle in rest in a slope can support another contacting vehicle without moving. Maybe the physics engine wake up the wheels when the rb is contacted with a CharacterController. This would explain why you can push the vehicles around, but I don't know how this could be fixed...
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I could wake it manually on contact I guess, from the player itself? How would I go about it?
     
  8. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    If you can push the vehicles and it moves, then the wheels are already waked up. From within EVP I can only specify whether the wheels are allowed or not to sleep, but the final sleep decision comes from the physic engine. Check out the method UpdateWheelSleep at VehicleController.cs.
     
  9. mihanocho

    mihanocho

    Joined:
    Mar 10, 2015
    Posts:
    296
    Edy's vehicle physics + Highly Detailed Car Model 2
     
    Edy and llJIMBOBll like this.
  10. mihanocho

    mihanocho

    Joined:
    Mar 10, 2015
    Posts:
    296
    I think you need to try to increase the number of polygons in the Collider. The collision Collider mesh does not change, thus it must be?
     
  11. Brocan

    Brocan

    Joined:
    Mar 22, 2012
    Posts:
    45
    @Edy, were the manual gears implemented?

    Is there any example of how config a truck? We've a truck with trailer (tractor+trailer), but at high speeds (> 60-70km/h) the tractor (and the trailer after it) ends sliping, no idea why.

    Thanks in advance
     
  12. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    The collider is a Convex collider. It's automatically built by Unity out of the provided collider's geometry, but the resulting convex hull cannot have more than 255 polygons. So providing a collider with more polygons will have no effect.

    For the Collider mesh to change it must be referenced from the VehicleDamage component.

    Not yet, but it's planned for the next release as an add-on component.

    I'd love to include a truck+trailer example if I'd have some 3D model I could include in the package. If you can provide one, I'll happily configure and include it in the next release.
     
  13. Brocan

    Brocan

    Joined:
    Mar 22, 2012
    Posts:
    45
  14. thedailyasset

    thedailyasset

    Joined:
    Jul 16, 2016
    Posts:
    10
    JamesArndt likes this.
  15. sbek

    sbek

    Joined:
    Dec 18, 2014
    Posts:
    1
    Hello, I'm trying to use EasyRoads and and Edy's Vehicle Physics. I create a road on a basic terrain, everything looks good, but when I start the game and drive a car on the road, the tires looks sunk into the road. There is no problem when I drive off the road. What can be the problem? I use Edy's camera prefab and car prefabs to test.

    scene.png
     
  16. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    354
    try changing the shader of easyroad mesh from easyroad to mobile/diffuse or something other default diffuse shaders.
     
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Just give road the same layer as terrain plus a collider.
     
  18. Phuzz

    Phuzz

    Joined:
    Mar 31, 2014
    Posts:
    48
    Hello,

    First thank you for this great Asset, makes things much easier and more fun :)

    Now for my question:

    I am importing FBX models into unity, everything seems to be working fine except that inputs seem to be the opposite direction. Throttle Input -1 Moves forward, and 1 moves backwards. A workaround for this was to rotate the wheels 180 degrees and adjusting the colliders based on that, now everything moves in the right direction, but Car ends up moving way too fast and speed shows in the negative. I imported my car into the EVP sample scene seems like the problem is in my car only, the sample one was fine. I just did that to narrow down the problem, but I cannot find a workaround for it or even fix the problem from my side. I even tried rotating the facing direction of the wheel to the opposite side before exporting to to FBX then into unity, still same problem. Please? and thank you
     
  19. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @Phuzz the vehicle's forward direction must be +Z. If meshes have a different orientation, you may rotate only the gameobjects containing these meshes, or put them into child gameobjects you can rotate, so the vehicle and wheelcolliders are not affected by the rotation. WheelColliders must have scale 1 and rotation 0 in their transform and all their ancestors.
     
  20. AurimasBlazulionis

    AurimasBlazulionis

    Joined:
    Aug 13, 2013
    Posts:
    209
    Hello,
    Thank you for your work, I have already implemented physics into my game and they make it a lot more realistic.

    But I have a little question.
    How do I make the car go really fast. I meant something like Bugatti fast. I have been experimenting inside the demo scene using racing coupes with many different values, but I have only been able to reach something like 280 km/h, but the vehicle gets really unstable, drives very unrealistically (tire traction needs to be set very high, mass has to be very low and curve is set to high). So is there a way to make a car drive fast but still feel realistic? What other values should be changed in order to achieve this?

    Thank you again.
     
  21. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
  22. Phuzz

    Phuzz

    Joined:
    Mar 31, 2014
    Posts:
    48
    Sorry for the late reply, Yes I solved this by having them (The Vehicle Mesh)rotated to the right direction before exporting to FBX :) Thank you for your support and great plugin.
     
    Edy likes this.
  23. Souliloquy

    Souliloquy

    Joined:
    Jul 23, 2012
    Posts:
    5
    I just wrote a script for car teleportation triggers - place it on a game object with a trigger collider (the trigger checkbox checked), set the teleportation target reference to any game object (the orientation will also be considered, not only the position) and specify which collider tags will teleport their parent VehicleController... check it out:

    https://gist.github.com/Souliloquy/7c912c4ff1d931bd48ba7f8e277000ea

    I'm doing some hacky stuff like waiting frames, if you can find a cleaner way to do it please let me know!
    Cheers
     
  24. quesadillas

    quesadillas

    Joined:
    May 1, 2015
    Posts:
    23
    ^ Oh, that happened to me too, but it was with custom road pieces I had, and it turns out that the mesh collider had to be set to Convex for it to actually collide with the Wheel Colliders for some reason.


    I am having some difficulty creating a custom script for vehicle AI. It has some similarities to the provided Randominput script but my difficulty lies in getting it to work with a waypoint system. I can get it to find the next waypoint just fine, but setting the throttle and steering to the correct numbers for it to actually reach that waypoint has been fairly difficult for me.

    Currently for steering, I take the dot product of the car's orientation (transform.forward) and waypointPosition - carPosition, then do the math to isolate the angle, which should be in the -360, 360 range. Then I get it into the -180, 180 range (for example, if the angle is 190, change it to -170). Then I divide it to get it down to the desired -1, 1 range for steering........ but I realized that that's not how the steering works. the number for steering means "this is how the wheels should be turned", not "this is the direction the car should be turning towards".

    Basically I think I'm going about this all wrong but I'm not sure what to do to fix it. Any ideas?
     
  25. Emre_U

    Emre_U

    Joined:
    Jan 27, 2015
    Posts:
    49
    Hi Edy

    I think I have broken my game without any backup when I want to try Unity 5.4 new visual effects from 5.3.

    What happens now.
    1- When the game starts WColliders Suspension Spring / Forward Friction / Sideways Friction parameters become 0 at inspector(after start).
    2- When car gets any speed (as there is no suspension?!) car starts to shake rapidly up and down until it breaks the terrain collider and starts to fall down. (Shake is very tight yet rapid)
    3- Even though I try to update values from other cars after starting the game and even though now I see car has suspension as car's body is lifted by suspension, again car is too tight and again rapidly shakes and break terrain collider at 30-40km/s

    This is a gif showing the bug and telemetry data
    Edit: You can see car is bouncing and sliding to right even though I am only accelerating and not steering. Yet ofc the ground is not fully flat.
    Edit2: Now checked your last vers on clean build and yes it is supposed to change values to zero. And you have fewer parameters now :D
    Edit3: Do you aware of any physix changes breaking your old scripts?? If so what is the best way to update to your last vers? (Honestly as game is broken now I am not really sure if I can make it worse yet a pro advice won't hurt)

    https://gfycat.com/GreedySnivelingHerculesbeetle
    http://gfycat.com/ShimmeringBitesizedGoldenretriever

    I am also trying to solve it. Mind you this is not the last vers of Edy's physics. It is coming from May 2015.

    http://gamejolt.com/games/yet-another-car-game/64040 the working game is here.
     
    Last edited: Sep 6, 2016
  26. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Suspension spring and damper are not modified. Friction parameters become zero, this is correct. EVP does not use the WheelCollider friction.

    Please write me to edy@vehiclephysics.com for further assistance. Include your invoice number.
     
    Emre_U likes this.
  27. timintal

    timintal

    Joined:
    Jul 23, 2012
    Posts:
    8
    Hi, Edy!
    In my game I want to add some obstacles on the track and one of them is a river. And I want to simulate something like river flow, which should push a car along with this flow. I tried to use rigidbody.MovePosition() in FixedUpdate(), but the car starts to shake. Is this a wrong way to implement this kind of stuff or may be I did something wrong?
    I also tried to add forces to cars rigidbody, and it feels right only when a flow direction close to collinear/anti-collinear with car direction but when flow close to perpendicular with car direction it looks strange. It feels like physics engine didn't allow car side movement, or side friction is too high. How can I achieve this effect of sliding car in flow direction in the right way? May be I have to mention that my gravity vector is (0, -30, 0).
     
  28. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @timintal achieving that effect may require some modifications to the EVP code. Please write me to edy@vehiclephysics.com and I'll be happy to help you. Include your invoice number.
     
  29. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    I am looking to make motorcycles with two and three wheels as well as a motor driven unicycle. How easy is this to set up single and dual inline wheels so the vehicle does not tip over and will angle or lean into turns? I am looking seriously at your Pro version. I am working for the folks who put on the car shows here in the southeastern US and to be able to dial real world numbers in is fantastic for the applications they want me to produce. I will also be attempting to emulate real world NASCAR cars. I note that some folks had issues with high speeds. These stock cars typically run between 185 and 220 top end.
     
  30. James-Williams

    James-Williams

    Joined:
    Aug 30, 2016
    Posts:
    26
    Good Morning, I am looking for a simple way to toggle the vehicle to
    reverse. I have tried a few different ways but none work to my liking. The
    issue is that we are creating a driving simulator and the players always
    begin in reverse to start the game. Once they have reversed away from the
    garage the vehicle is put into drive automatically. Ideally there is a
    trigger volume and OnTriggerStay the car is in reverse, OnTriggerExit the
    car is in drive.

    Here is a sample of what I wrote:

    Code (CSharp):
    1.  void OnTriggerStay(Collider other)
    2.     {
    3.         VehicleController vc = other.gameObject.GetComponentInParent<VehicleController>();
    4.  
    5.         float v = Input.GetAxis("VerticalReverse");
    6.  
    7.         if(v > 0)
    8.         {
    9.             vc.throttleInput = -.7f;
    10.             vc.brakeInput = 0f;
    11.             vc.steerInput = .5f;
    12.             //v = -1f;
    13.         }
    14.     }
    15.  
    16.     void OnTriggerExit(Collider other)
    17.     {
    18.         Destroy(this.gameObject);
    19.     }
     
  31. Ethwood

    Ethwood

    Joined:
    Nov 6, 2016
    Posts:
    39
    Hey Edy, Great asset!

    The parameters under WheelCollider, such as any parameters under Sideways Friction don't seem to have any effect at all in my game. I'm trying to make the car turn sharply but even the slightest turning makes it spin out easily. Played with all other values like COM and drag force.

    Are WheelCollider parameters not working in Unity 5 anymore?
     
  32. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Motorcycles: actually the easiest trick is to put the center of mass beyond the ground. I'm working on arcade motorcycle physics, which would work with unicycle as well.

    I'm emulating fast racing cars successfully, including high-end supercars and formula-1 style open cars. I don't see any significant difficulty on setting up NASCAR cars with Vehicle Physics Pro. We would only need good car data.
     
  33. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @James-Williams please write me to edy@vehiclephysics.com for further assistance.

    WheelCollider friction parameters in Edy's Vehicle Physics have no effect. Indeed, they are all set to zero in runtime. Only radius, suspension distance, suspension spring and suspension damper are configured at the WheelCollider. All other values are meaningless to EVP.
     
  34. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Hey, Edy, thanks for a great asset. I just won this in the #UnityChristmas giveaway contest. This was something on my wish list for a while so it was a pleasant surprise to win a license. We definitely have some plans for a game using this amazing asset.
     
  35. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Cool @magique, congratulations! Let me know if I can help you with it.
     
    magique likes this.
  36. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,163
    Hi @Edy
    I am thinking to buy this asset for demo scene of my track builder system.
    . I have few questions
    1) Does it allow manual gear?
    2) Is there any graph UI like for speed, gear, etc?
    3) What about 3 wheels or 2 wheels?
    Thanks.
    Cheers
     
  37. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Hi @antoripa, many thanks!

    1) No, but it may be easily implemented via add-on script. I'll be including a manual gear script in next version.
    2) I'm working on that right now.
    3) No problem on 3 wheels. 2 wheels work but there's not equilibrium implemented. The quick trick is moving the CoM beyond the ground. I'll be including motorcycle physics in an upcoming version.

    Let me know if I can help you further!
    Cheers,
    Edy
     
    Deleted User and antoripa like this.
  38. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,163
    Hi @Edy
    thanks you for your answer.
    Basically I would like to know if you have any script that I can use as starting point for themanual gear patch and what is your eta for UI release. Thanks .. .I am gonna send a PM for another topic ..
    Cheers,
     
  39. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I just started playing with this today and I'm very impressed. The system is working smooth and very fast. I'm looking for some quick tips on adjusting vehicle parameters in order to have vehicles less realistic and more arcade style. Basically, I'd like to have cars that can fly around tracks at breakneck speeds and not have very much drift or sliding and that can turn rapidly even around sharp turns. What parameters would I tweak to accomplish this?
     
  40. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @magique glad you like it!
    These settings at the Vehicle Controller component turn most vehicles into arcade vehicles a'la Mario Kart or Outrun:
    • Tire Friction: 3
    • Anti-roll: 0.9
    • Force Curve Shape: 0.99
     
    antoripa and Hormic like this.
  41. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Fantastic. That works really well.
     
  42. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    OK, so I've set up some AI cars using Racing Game Starter Kit and EVP, but even with these settings and some other tweaks, I still get a lot of slipping that I'd like to eliminate if possible. I think the main problem is slipping due to braking. Whenever the AI cars brake, they seem to slip side to side even if only slightly now. But it happens quite a lot and it would be nice to not have persistent slipping. I tried to make changes to slip parameters and give the car maximum steer and braking assist, but still not quite there. Any more suggestions would be appreciated.

    [EDIT]
    I've been playing with every value I can think of and the cars are certainly doing better now. Less going out of control and more capable of making it around a difficult track. I'm still tweaking and trying things though so if there are any more suggestions I am open to hearing them.

    [EDIT 2]
    Still not there yet. I have a new track with all flat ground and very easy to navigate around and all the cars with EVP on them are always bouncing up and down in the rear suspension and so easily prone to slip. Is there no way to get the cars to behave properly? When I use the default RGSK physics then I don't get this kind of behavior, but it also performs a lot worse than EVP.

    [EDIT 3]
    It seems a lot of my own tweaks are responsible for most of the issues. I went back to settings from a sample car and tweaked from there and it's looking better.
     
    Last edited: Jan 2, 2017
  43. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm having serious problems configuring new vehicles. I'm following the video tutorial, but 2 things are going wrong. First, after configuring the wheels and clicking on Adjust wheel colliders to their meshes, the results don't line up. See image below:

    upload_2017-1-2_14-33-23.png

    So, I manually move the circles so they match the wheels. However, once I get the vehicle in game, the whole wheel setup is rotated 90 degrees. See below.

    upload_2017-1-2_14-35-13.png

    What am I doing wrong?

    [EDIT]
    Well, I've tried with some new cars I bought and have no issues. So it has something to do with the way those other cars are built I think.
     
    Last edited: Jan 2, 2017
  44. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Certainly it's very strange.

    - Ensure that "Wheel Transform" fields are pointing to "WheelFL", "WheelFR", etc. meshes in the vehicle, not "WheelFL" etc WheelColliders.
    - "Forward" should be +Z in the vehicle and the wheels.
    - Children objects shouldn't have any rotation or scale applied.

    Forum board is typically used for quick questions on EVP. If you need continued detailed support, the best channel is by email. Feel free to write me to edy@vehiclephysics.com (include the invoice number for EVP).
     
    CandraWi likes this.
  45. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Thanks. I may give those cars another try. Btw, I figured out that the way to really give the cars better handling and avoid slippage is to increase the angular drag on the rigidbody. I have my cars around10-12 and they can really fly around the track now.
     
    JamesArndt likes this.
  46. Deleted User

    Deleted User

    Guest

    Edy could you please also integrate motorbikes? EPV feels not "complete" without motorbikes, they are also vehicles and if people want to make games like GTA or open world games with cars, motorbikes should also be possible to make. ^^

    And does EPV work in multiplayer, for example in combination with Third Person Controller from Opsive?
     
    Last edited by a moderator: Jan 4, 2017
  47. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Deleted User likes this.
  48. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Potential Buyer here ....
    has anyone ever created RC style vehicles .. I'm wondering how the physics would react being scaled down by 32 scale

    I'm interested in creating a R.C Monster Truck style game with toy cars.
    skid marks on uneven ground... is this possible ?
    How many engine sample sounds does the pack contain ?

    All the examples I've seen to date have been in flat land & real world scale.
     
  49. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    @Banksy Scale should always be 1 in vehicles. However, you can just create small RC vehicles and small playgrounds, everything real world scale. I've tested EVP to work properly with vehicles as lightweight as 1 kg.

    Yes, skidmarks and tire marks work on uneven ground out of the box:

    upload_2017-1-15_13-18-12.png

    The pack contain three different engine samples as for the types of vehicles included as examples.
     
  50. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi @Edy

    I did try drift car, but its not stable. It difficult to drift car even i am using mobile accel control. Could you add a class to make it stable and more easy to control like this: