# Edy's Vehicle Physics - official thread

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

1. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
I'm not sure to have understood you about "the car hits his bumper sooner", but the picture is right. When the car is about to land the ray is calculated in angle.

However, that's one of the most insignificant and less noticeable issues of all I've had to deal with. Really. I strongly doubt there would be any noticeable difference at all among calculating the ray vertically or using the local angle, other that having unwanted side effects. In fact, when landing in so hard angles, it's more likely to impact with the car's bodywork first. Especially in the typical low-suspension cars. When the WheelCollider reaches the ground then the angle is much closer to the vertical.

Of course! That prototype uses WheelCollider for suspension and getting the downforce only. Everything else behaves as a real tire with simplified friction.
But the raycasts are still calculated using the local angle. The properly calculated tire forces make the difference, not the angle

2. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
well basically what i meant is: because ray is at an angle when the car lands from jump... you basically lose some ground clearance... lets say 5cm when jumping at 30degrees angle with some sports car with low suspension...

sure thats not much, only 5 cm, but i think its noticable, and because of those 5cm, the bodywork of the car will hit the ground sooner than it would with proper tire... thats what i meant with "the car hits his bumper sooner", because the tire actually goes through ground, and detects collision later than it should... i mean i hope its more clear now...

but yeh ur right, thats only nitpicking and probably 90% of players wouldnt notice that... the thing is i really like jumping with cars, in games, so yeh i do notice stuff like that

on the other hand, i played a lot yesterday, and its really not noticeable on low sports car, because its just that low hehe

ye maybe thats the catch, i dont know heh but it does feel alot better when jumping than with what we have now... atleast to me
just friction now... and we have a winner here

Last edited: Nov 3, 2013
3. ### Der_Kevin

Joined:
Jan 2, 2013
Posts:
517
Hey! Thanks for you last reply, helps a lot

so, i have a new question.
I am currently trying to set up the damage part with the deforming stuff but whatever i do, the results are just way to little. ive put the Sport Coupe into my scene to see whats happening and the damage there just work as it should be but when iam using my own car the impact is just so little. it works, thats not the problem but the deformation is just nearly not visible

here is the screenshot of my setup. maybe you see a mistake at first sight:

i also tried to put the force down to zero and the multiplier up to 100 but nothing realy changed.
so, maybe you have a hint for me. would be great

4. ### Der_Kevin

Joined:
Jan 2, 2013
Posts:
517
And another one:
is it possbile to let the car slow down when I am driving above gras or sand or driving on an other layer than my road layer?
and enable "always draw skidmarks" when he is driving off track?

Last edited: Nov 3, 2013

Joined:
Sep 3, 2011
Posts:
62
Great news! Are there any plans to support manual gears and force feedback as well?

Last edited: Nov 7, 2013
6. ### HighFlyer

Joined:
Dec 27, 2012
Posts:
1
Hi Edy,
one question: is your physics working as well for bikes? Or do you know a good bike physics? Artwork ist not necessary, only the physics and behaviour - thanks!
And: for 4-wheeled cars: is there a possibility to test your package before I buy it just to ensure that it is usable for my context? Thanks a lot?

7. ### MoribitoMT

Joined:
Jun 1, 2013
Posts:
301
I have angle problems with custom models

Blender3D car model to Unity3D, then I set everything. But car wheels and colliders has different angles of 90 degree. Tyres looked very much screwed.

Which angles should be correct, if tried many angle I just cannot find the right combination lolll

8. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
you need to properly set pivot points (proper rotation) when exporting from blender. and also in exporting options, which axis is facing upwards... watch video on first page

you can drag material to terrain, from that example scene... "offroad track" but i dont know how to change parameters...
you will want to have different terrains for road and dirt/grass/sand though... because that is the only easy way of doing that...

Last edited: Nov 9, 2013
9. ### DarkJoney

Joined:
Jan 31, 2013
Posts:
24
Hello everyone, I have a question:
When I play in game in Editor, they are working.
When I build game, and play in it from file, I dont see skidmarks.
Where is trouble? How to fix that?
Unity3D is 4.2.2

Last edited: Nov 9, 2013
10. ### bloobie

Joined:
Apr 1, 2010
Posts:
13
hi there,

i´ve i noob question i think

i have bought your physics script and tryed to do your tutorial :basic scene (http://projects.edy.es/trac/edy_vehicle-physics/wiki/VehiclePhysicsTutorial)

now i have the problem that i wrote the car name (EmptyCar) into the CarMain script (var Cars : CarControl[EmptyCar] but i get an error that i should insert an ; behind CarControl

did i missunderstood your instructions or did i something else wrong?

thx

11. ### Skylabh

Joined:
Jun 26, 2011
Posts:
18
Hi Edy,

I was wondering if there is a variable in the scripts about the wheels rpm ? Because i want to test something about it. Thanks.

@bloobie,

You do not need to write a name for the variable " Cars " in the CarMain script. Just drag and drop the emptycar prefab on the variable " Cars ", in the inspector.

12. ### bloobie

Joined:
Apr 1, 2010
Posts:
13
@ Skylabh thx but how can i do that?
if i select the main script there is nothing in the inspector than the script (-;

13. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
1. Create new project
2. Delete Main Camera in hierarchy
3. Import edy vehicle physics
4. in project panel, go to edyvehiclephysics/Prefabs folder and drag into hierarchy panel following prefabs: Main, MainCamera, MapCamera,Skidmarks
5. Put prefab of your car into hierarchy panel, and configure it with scripts from edy's vehicle physics. You can also configure MainCamera and MapCamera, and you can delete child objects of Main, they are mirrors, you probably dont need them.
6. Click on Main in hierarchy panel and put Cars Size to 1, and drag your car from hierarchy panel into Element 0 slot.

you should be good to go if you configured your car before (you can test it with cars that come with edy's asset... to find them go to edyvehiclephysics/Example/Vehicles)

14. ### bloobie

Joined:
Apr 1, 2010
Posts:
13
ok i did point 1 till 4 an then i draged the EmptyCar prefab from edyvehiclephysics/Prefabs into the hierachy but then i don´t know how to configure the car with the scripts but i think the emptycar is configured several scripts etc are assigned to it

in the documentation is written:"Add each user-controlable vehicle to the list Main > CarMain script > Cars. Ensure that the Cars array contains no empty slots" how can i do that? where is this list "Main"

sorry for bugging you and thx for your help

15. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
this is step 6...

and i think you should first learn a bit more unity... but ok everyone has to start somewhere...

and dont drag emptycar prefab in... drag sportscar prefab in or pickuptruck, i told you where to get that also...

Joined:
Apr 1, 2010
Posts:
13
17. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
if you would have followed my instructions specifically, i said create new project and import edy's physics in... you probably didnt import example forlder when you were importing this edy's physics, so now you can reinport it agian but this time do not uncheck any check boxes

18. ### kapilan

Joined:
Apr 24, 2013
Posts:
2
Do anybody know how to simulate ABS, TC and ESP in edy's physics live demo ? I tried to check the ABS ( Anti Brake System ) by driving the vehicle until it reaches the high speed and tried to turn it. But i couldn't notice any significant differences when ABS on and ABS off.

19. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
Surely there's some scaling involved. Probably the mesh you're trying to deform has some scale applied that makes the deformation not noticeable.

The friction force due to the material is calculated at the CarWheel script. Look for sharedMaterial. The force is based on the material's dynamicFriction value.

About drawing skidmarks, you have a detailed answer in the FAQ at the first post

Of course!

Bikes are not supported directly, but you could simulate them using tricks (i.e. lowering center of mass beyond the surface, using 4 wheels but the mesh of a bike...)
About the 2nd question, feel free to ask me as many questions as need. You could even send me a sample of your content so I could give you better advice. Rest assured that if I see that it wouldn't fit, or it would be too difficult to adapt, I'd recommend you not to use my package.

I also had those problems. I used to modify the models in Blender first, but it quickly become a big mess. So I got tired of that and wrote the definitive Blender To Unity3D importer. It imports the models from Blender perfectly keeping all the original angles and transforms. I still have to test it with animations. Once it's completed I'll publish it at my blog.

Yes, they are exposed at the CarVisuals script: spinRateFL, spinRateFR, etc. (m/s)
As example, they are read from CarSound for calculating the engine RPMs.

The best way to see the difference is in the friction curves. At the demo, press B (Telemetry) then shift-B (curves). You can see the friction curves which represent tire slip (m/s) in the horizontal axis, and the grip ratio at the vertical axis. There are separate curves for forwards and sideways grip per wheel. Try braking the vehicle with ABS on and off. You'll see how the ABS limits the amount of slip so the vehicle always applies the maximum grip. Without ABS the slip goes up to the vehicle's velocity, so the grip is worse. "How much worse" depends on the asymptote of the friction curve.

20. ### stuckon3d

Joined:
Nov 9, 2013
Posts:
7
hi guys, im a newbie when it comes to programming, I just installed edy into a project i was working on and now i'm getting all kind of "compiler errors". I have a presentation soon and cant get my project to start. How can i revert to a previous version before i install the edy asset? is there a way to uninstall the asset so i can reinstall all my other plugins. I did not know importing an asset could be so destructive. I cant afford to lose weeks of work. I though import assets into a new scene would not screw my other scenes in the project. Apparently that is not the case
If anyone could me help, it will be very appreciated.

thank you

21. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
backups... backups... backups

you can just delete edy's folder, that might help with all the errors... but do a backup first, in case that F***s up things even more

22. ### stuckon3d

Joined:
Nov 9, 2013
Posts:
7
removing it and re-importing everything else worked. thanks.

23. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
Actually I cannot conceive working on any project without having at least a local GIT repository configured on it. GIT may be defined as a "file system with history/undo". Setting up a local repo inside the project folder is trivial. Once you get used to it you cannot live without it. It gives you the freedom of trying anything, even when it could screw up everything, and having the chance of rolling back to the previous state with a single command.

24. ### Skylabh

Joined:
Jun 26, 2011
Posts:
18
Hi Edy,

Do you think that a waypoints system could be interesting to implement ? Since a car can be used directly in a new scene. I know that there is the External Input function with the scripts, so the car is driving randomly, but it would be nice to see the car follow a path. In brief, having a road traffic in the scene.

I have already tried a waypoints system but it does not work very well with your scripts ( and this is normal after all ).

25. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
hey edy, one question...

we cant seem to figure out, how to lower air time of cars... when they jump, they jump unrealisticly far...

we tried messing with rigidbody mass, rigidbody drag, your airDrag... nothing works...

the thing is, we have quite a few jumps in our game, and cars just jump too far, in real life, car going at 50km/h, wouldnt jump for like 5 meters or something... its way too exaggerated...

26. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
The iRDS system implements the AI via the External Input function: the AI system just "moves" the same controls as the user. So a good waypoint system is possible via External Input. I might improve the "random" example in the next version so the car actually does something.

It's not exaggerated, it's simply the "ideal case". The physics work like in the real world: if you throw anything at 50 km/h over a jump, it will behave very similar in the real life than in a simulated world with the gravity set to 9,81 m/s2 (remember the parabolic throw exercises at high school). About cars, if you build the same scenario in the real world the car would behave in the same way in an ideal case: provided that the suspension will be able to support the jump impact, the bodywork doesn't absorb energy, etc. Even the point of view (zoom, movement, etc.) may affect the perception of the jump.

Anyways: Many times the realistic values must be tweaked in order to give (ironically) a more realistic perception. For lowering the air time of the cars I recommend you to add artificial gravity force to the car:

On Start:
set rigidbody.useGravity = false

On FixedUpdate:

Change 1.5 for a ratio that works fine for you. 1.0 would work exactly as the regular rigidbody.useGravity option. 2.0 means twice the gravity. Note that you might have to adjust the settings for your vehicles, as the additional downforce causes stronger tire friction.

rhodnius likes this.
27. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
im pretty sure jumping is exaggerated, basically everyone in my team noticed that...

one guy that joined the team, first thing he said when he tried the demo: "wow what is wrong with jumping"

but okey... and there is no easy fix for it, except maybe checking if wheels are touching the ground, and if all 4 are off the ground, apply small down force to car... but not sure if that would work fluently... would look a bit stupid probably

maybe that addForce but then friction is bigger and would have to change bunch of other parameters

anyways onto my new question...

it is related to jumping again...

what we did is... we made small low poly jump ramp... you can see faces of it on screenshot... when car drives on this ramp, the ramp acts as boost, it acts as if you would applied nitro to the car, it gives him extra force.... but there is no scripts on it or anything, it is just imported model, and mesh collider on it...

there is a bug either in edy's script or in unity.... also we tried making loop... for cars to do loops... same problem, it gives huge boosts to car... i guess this script doesnt handle slopes very well?

Last edited: Dec 11, 2013
28. ### lalamax3d

Joined:
Aug 23, 2012
Posts:
17
Hi Edy,
i have a question. i want to control vehical via gestures rather than wsad. basic control for speed and direction (steering). can you guide me towards basic steps needed to accomplish this.
regards,lala

29. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
I disagree, but I see your point. In vehicle physics we are so used to certain behaviors that many times the results aren't what we expect when experiencing with truly realistic parameters. For instance: in reality most cars can't do as heavy turns as seen in most games (Vehicle Physics Demo included). Real vehicles tend to go straight at turns even at relatively low speeds. However you'll probably find "unrealistic" a car that can't do sharp turns at over 50 km/h (30 mph).

In an ideal scenario throwing anything at certain speed, with certain angle, and a gravity of 9,81 m/s2 will follow a parabolic path and the impact point with the ground can be predicted with great precision. In Edy's Vehicle Physics that's entirely handled by Unity's underlying physics engine. There are many other factors that affect the "perception" of realism: suspension setting, scenery scales vs. vehicle scale, acceleration, top speed...

WheelCollider component.

Due to the (in)famous bug in the implementation of this component we are forced to apply the max torque to the wheel and limit the top speed with the air drag. Imagine that the wheel is spinning at a higher rate of the ground underneath. The resulting forward force depends on the vertical downforce. Thus, when the vehicle enters the ramp the downforce is suddenly increased and the force is boosted.

Suggested workaround: I'd try configuring the physic material for the ramp so it causes some "drag" (like offroad terrain), preventing the vehicle to be boosted. Terrain drag is applied in the CarWheel script, look for AddForceAtPosition.

The next version of Vehicle Physics I'm working on is based on a custom tire model that behaves truly realistic without any of these problems.

30. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
ye i guess perspective is different from person to person...

and yes i was afraid that its wheelcollider problem... well i guess we will just wait on ur new version i did think of using friction like offroad terrain... just never did it... i guess i could try that

anyways i got 2 more problems...

i have been playing with bus for a bit... trying to make some bus simulator for mobile phones... and first problem that im having, is how do i detect if bus collided with something, so that i can give penalty to player? bus normally collides with buildings for example... but it just wont trigger my collider event in playmaker...

what i did was: i went into CollidersBody, and removed all colliders except bodyMain... and on bodyMain i have playmaker script that just detects collision, nothing else...

it works if i put same playmaker FSM on normal cube... so it must be something with bus body collider

it works if i put it on root of the Bus, where all scripts are, but i dont want that... that just sends collider for the road all the time... i just want it to work with body collider, and somehow its not working

-------

second problem that im having, is... i suck at programming, so im using playmaker. and problem is that i want to use car external input script.

but i just cant control those values that are in that script with playmaker
i can only control public variables that can be changed in inspector too...

so can you kindly modify this script so these variables will be public and accessible from inspector? then i will be able to put steerInput to 1 or -1, and motorInput to 1, and stuff like that... i just need variables that can be changed in inspector, and then i can easily access and modify them in playmaker...

31. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
I don't know how PlayMaker works so I cannot give you a specific solution. However, note that in Edy's Vehicle Physics some of the colliders are also registered in the property CarVisuals.ignoredColliders. These colliders are moved to layer 2 (IgnoreRaycast) at some point of the calculations and then back to layer 0. If PlayMaker uses layers for the colliders, then this may be the cause of the problem.

You don't need to use the CarExternalInput script. Those properties (steerInput, motorInput, brakeInput, etc.) are published properties of the script CarControl. They are accessible from inspector. You should be able to use them in Playmaker directly.

32. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
i thought of that before too... i think that is the problem yes... that collider is in fact in those "ignored colliders" so i will try to find a way around this...
oh if only it was that easy... modifying those values in inspector doesnt affect the movement at all, these values seems to be only for information... i tried doing that a long time ago, but they are hardcoded to button keys i belive

it changed the value, but bus doesnt move at all

33. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
They are not hardcoded, they are controlled from CarMain. Something like the demo's "playmaker"-like component.

Ensure the vehicle is not listed in the CarMain.Cars list. Also disable CarControl.readUserInput. Now you can control the vehicle by modifying those properties in the Inspector, so PlayMaker should be able to modify them as well.

34. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
thanks Edy, now it works... now i just have to fix camera and speedometer, but that is easy

35. ### austint30

Joined:
Jul 1, 2013
Posts:
72
Can we have a free version of your project? It should be limited though. Maybe only one car and no prefabs.

36. ### Antigono

Joined:
Oct 20, 2013
Posts:
63
Hello, how are you? first sorry for my English
I am interested in purchasing this package, I just want to ask you some questions

1) Is there any road map?, Does this package will continue to update?

2) Is it possible to add new "effects" the movement of vehicles, either through scripts or other method? for example, an effect of irregular ground as can be seen in this video (random example, surely there are better), where you can see how the car vibrates while it is in motion.:

Because all I saw so far, the car seems static while moving. Of course it may be realistic when the ground is smooth, but I wanted to know if possible what I asked.

Thanks!

37. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
Yes! I'm working in a new version which uses a new approach for simulating the tire and the vehicle's internals. I expect this new version to be available around Summer.

Sure! In that videos only the visible mesh vibrates, but the underneath "physic" vehicle moves in a perfectly flat and smooth terrain, just like in my Demo. You could add a script that randomly changes the rotation of the vehicle's visual mesh according to the current speed and terrain (i.e. the movement is bigger if offroad).

38. ### angel_m

Joined:
Nov 4, 2005
Posts:
1,160
Is the GIT repository the only way to get the last version of the Asset?
I say that because I find GIT is a complex system, a mess, and sincerelly I see it unnecessary, for using it in small projects like this.

Last edited: Jan 20, 2014
39. ### cl9-2

Joined:
May 31, 2013
Posts:
417
Hello Edy,

Your Unity forum inbox is full and also I'm waiting for your email response for my support question.

Thank you.

40. ### zeppeldep

Joined:
Jun 2, 2013
Posts:
27
Support for Left side driving.
Somebody probably asked this already, sorry if it is repeated. The vehicles in the web demo are all right side drive vehicles. Does the package also support left side drive vehicles? Are sample left side drive vehicles included in the package?
Just need to know this before purchasing. Looks like this is one of the best driving packages available for Unity.

41. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
Yes, but you don't need to install GIT. You can navigate the repository as web page and download the latest version (or any previous update) as zip file.

I've already replied to all questions in my email. Please let me know if I missed something.

42. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
That's only a cosmetic setting. In fact, I've set up the Sport Coupe for Left side driving by doing a minor change in hierarchy and setting the mesh's X scale to -1. Also, changed the sign for the X position in the driver's camera transform. You should be able to do that in any vehicle:

43. ### principante

Joined:
Jan 23, 2014
Posts:
1
no matter camsmoothfollow me please can you tell me the script or tell me the solution

44. ### Gooseman_1977

Joined:
Aug 15, 2013
Posts:
89
Hi Edy, I sent you an email regarding the C# scripts.
I was wondering if you got it or not..

minh_le@telus.net is my email.

45. ### Navid

Joined:
Sep 3, 2012
Posts:
39
Hi Edy,
any tutorial or hints for mobile touch controlling?

46. ### Gooseman_1977

Joined:
Aug 15, 2013
Posts:
89
Is anyone else using the C# scripts ? I just downloaded the latest C# scripts for Edy's physics and it's very finnicky when going switching from 1st gear --> Reverse, and vice versa.

47. ### bizilux1

Joined:
Jun 6, 2013
Posts:
151
turn off reverse requires stop boolean

48. ### Edy

Joined:
Jun 3, 2010
Posts:
2,414
All input from the user is managed at the script CarMain, function "SendInput". You can rewrite this function to your liking in order to read the from any other device or script.

@Gooseman_1977
Yes, recevied and answered some time ago. Send me an email if you need further assistance

49. ### lavz24

Joined:
Mar 14, 2013
Posts:
45
Hola!

Estoy tratando de hacer que el Sport Coupe que viene por defecto vaya mas rapido y con mayor angulo de control en las curvas, pero al ajustar los valores en su documento de ayuda, logro que vaya mas rapido(reduciendo el air drag) pero no importa los valores que utilice en los drifts y grip, el auto se sigue volteando al cruzar el volante(cambiando el max steer de 45 a 60). Cual es la mejor manera de hacer que los valores por defecto vayan mas rapido y se pueda cruzar a mayor angulo sin que el auto se deslize o de vueltas?

Joined:
Jun 3, 2010
Posts:
2,414