Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Edy's Vehicle Physics - official thread

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

  1. Gooseman_1977

    Gooseman_1977

    Joined:
    Aug 15, 2013
    Posts:
    89
    Hi Edy,
    How do I make the car go faster in REVERSE without affecting the forward speed?

    thanks, btw, Loving your addon.. It's saved me months of time in development :)
     
  2. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    Hi.
    I installed Edy's Vehicle Physics but if there's no ground under a tire and it's in air it falls down, how to make boarder to prevent it from falling?
    the car is offroad.
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Top speed is limited by the air drag parameters (CarControl script). You can adjust them depending on the vehicle traveling forwards or backwards.
    You're welcome! Let me know when you release your project.


    "if there's no ground under a tire and it's in air it falls down"... well, sounds like the expected behavior to me :D
     
  4. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    for me, too. When there's nothing under a wheel, it falls down, can you tell me why it happens.

    see the photo
     
  5. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Hi there .. how do you get the C# version? I purchased Edy's Physics on Sunday.
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Seems to be some parameter that is not configured correctly. Maybe something with the scale of the vehicle?

    Please write me to edytado @ gmail.com including your invoice number :)
     
  7. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    i made the physics twice, in case of other car it worked fine...
    as for this car i reduced its scale, maybe it caused the problem? and if it's cause' of it, shall i import with the size i want to have in the game?
    when the car is upside down, the tires go far above...
     
  8. Deleted

    Deleted

    Joined:
    Dec 8, 2012
    Posts:
    16
    Launching the demo or simply using a simple scene with an empty car makes this error appear:

    The same field name is serialized multiple names in the class or it's parent class. This is not supported: Base(CarExternalInputRandom) m_targetSteer


    How to get rid of it?
     
  9. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    HI
    how to decrease rear power?
     
  10. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Edy responded immediately with a link to download the C# version.
    Excellent support.
     
  11. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Could not reproduce that here. Try right-clicking the Project window and "Reimport All".

    Docs for configuring the power-related parameters are here:
    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarControl

    I've had to do many tricks to deal with scaled models (the pickup trucks from the Demo are actually scaled), but they don't seem to work in all cases. I recommend you to keep the main gameobjects in the vehicle hierarchy to scale 1: root, scripts, wheels, colliders... Then you can configure the visual meshes as isolated children and apply them the scale of your choice.
     
  12. sarim987

    sarim987

    Joined:
    Feb 13, 2014
    Posts:
    7
    Hello, its been several hours and I am still unable to find the answer to this. I am trying to implement touch controls for my game. I have learned how to implement them but i have one issue. Where is the code that actually makes the car go? In the CarMain.cs. Is this the correct line to go forward or is it combination of other lines too?? Im soo confused.
     
  13. sarim987

    sarim987

    Joined:
    Feb 13, 2014
    Posts:
    7
    Is this how you do it?
     
  14. rhushabh164

    rhushabh164

    Joined:
    Feb 18, 2014
    Posts:
    1
    Hi Edy,
    I wanted to ask you that , what changes are required if we use your Edy's vehicle physics on an android.
    For example, do we have to change the WASD input ? also what other changes are required.
    I am new to unity , so maybe a beginners question.
     
  15. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    All input from the user is handled from a single function. It actually converts the standard input into motorInput, brakeInput, and steerInput values that are then sent to the same properties in the vehicle. You can rewrite that function, or you could write your own to control the vehicles via the *Input properties.
     
  16. cl9

    cl9

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

    What is the status of the new tire physics?

    In addition to the new tire physics, are you considering adding an AI or traffic system?
     
  17. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Glad you asked! Status is Truly Amazing :)

    $2014-02-24_132553.jpg

    I've developed a coherent tire friction model covering both static and dynamic friction, any tire friction curve allowed (basic, spline, pacejka, 3D, etc), tire relaxation, high torques at low velocities, perfect combination of power torque and brake torque including retention in slopes (as in the pic), perfect static friction in any terrain... Actual tests use the simplest possible tire friction shape. Calculations for the friction are done in a 3D-shaped friction curve built with the provided friction parameters (parametric, curves, experimental data...).

    Now I'm working in the vehicle's internals. I'm developing a modular system where you can connect the components in any combination (differentials, motors, gearboxes, etc). Any vehicle is possible both externally (number of wheels) and internally. A base class is provided so you could easily develop your own transmission components.

    Everything gets integrated from the tires up to the motor(s) and the final torques are converted to actual forces in the tires. The system is structured around my own physics solver that runs independently of the actual Unity's physics solver. Thus, if you need more accuracy you can increase the Euler steps or use Runge-Kutta 4 (or implement the integration method of your choice) without actually pushing Unity's physics time step. For instance, with Euler=1 the solver runs at the same rate as Unity's Physics. Euler=2 means two integrations are performed per fixed time step. RK4 uses four calculations per fixed time step. This setting is configured per-vehicle: you can give more accuracy to the player's vehicle and less for others.

    Not at this time. I'm now focusing on vehicle's internal components and the sample vehicles for shipping with the Vehicle Physics package. An excellent tool for racing AI is iRDS: https://www.assetstore.unity3d.com/#/content/7294
     
    rhodnius likes this.
  18. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Hi Edy and others that participate here...

    On selecting a car I want the newly selected car to replace the current car at the starting position, starting rotation (0,0,0) and standing still.

    I tried to do it by "hiding" all the cars in a different position. Then I altered CarMain.CS. At the end of DisableCar I set the Car rigid body position to the hide position (far away, out of sight). In SelectCar after m_Car = Car , I set the m_Car rigid body position to be the start position.

    My crazy attempt kind of worked. Looks funny, but not at all good. The cars get damaged between the 2 positions, and bounce around.

    What I probably need is to disable rigid body before transform - the enable again - correct? Very wrong?

    Please help.

    Thx, Kevin.
     
  19. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    I'd try setting the Rigidbody's kinematic flag to true and disabling the CarDamage script. Disable kinematic and enable the script after moving the transform to the new position.
     
  20. malyna

    malyna

    Joined:
    Jul 9, 2010
    Posts:
    105
    So when is the release ? I can't wait :D
     
  21. EndUser

    EndUser

    Joined:
    Aug 12, 2013
    Posts:
    51
    Salut, Edy!

    I have read http://forum.unity3d.com/threads/50643-How-to-make-a-physically-real-stable-car-with-WheelColliders. An excellent article and an outstanding demos, thank you!

    Anyways, I suppose that WW2 tanks had none of auto-stability devices you described, at least those tanks I have heard about.

    Imagine a T-34 tank, 30'500 kg, 10 wheels on Christie suspension and none of mechanical transfers of the load from one side to another.

    $t34_1.gif
    (from http://armor.kiev.ua/Tank/design/suspension/2/)

    In Unity3D T-34 or all other tanks flip over the same way any stupid brick-o-wheels flips over, no matter 10, 20 or only 4 wheel colliders attached. And I never heard that IRL these armoured vehicles were lost en masse due to flipping over.

    What's the matter? What's the trick?
     
    Last edited: Mar 1, 2014
  22. sarim987

    sarim987

    Joined:
    Feb 13, 2014
    Posts:
    7
    Hi, I am a noob and im really confused about this issue. What line of code/codes is actually making the car accelerate? i am trying to add touch controls but i dont know which code is actually making the car go.
     
  23. EndUser

    EndUser

    Joined:
    Aug 12, 2013
    Posts:
    51
    WheelCollider wheelForePortCollider;
    wheelForePortCollider.motorTorque = 100;
     
  24. sarim987

    sarim987

    Joined:
    Feb 13, 2014
    Posts:
    7
    is that in the CarMain? because i think edy said something about it being in the CarMain
     
  25. EndUser

    EndUser

    Joined:
    Aug 12, 2013
    Posts:
    51
    Does it matter?

    You asked how a WheelCollider can pass the momentum to the car, and I answered "via .motorTorque=" value.

    Wherever this commands is in the codebase.
     
  26. sarim987

    sarim987

    Joined:
    Feb 13, 2014
    Posts:
    7
    I am sorry, i think i wasnt clear with my question, i am wondering which line of code is controlling the car with the arrow keys?
    Would this be that line?
    I am trying to implement touch controls for mobile devices
     
  27. Dk2590

    Dk2590

    Joined:
    Mar 2, 2014
    Posts:
    1
    Can the controls for the car be handled outside the carmain script? (for example, on a guitexture or button) or do controls have to be handled within the car main?
     
  28. Darzentas

    Darzentas

    Joined:
    Apr 9, 2013
    Posts:
    6
    Hello!

    I was hoping I could get some help with a problem.

    I am having an issue with the car steering drift.
    For this project I am working on, I need a number of cars to move forwards on a straight road, similar to a multilane highway.
    I thought it would be a simple matter of settings the motor input of each vehicle to 1 and letting them go but every one of the vehicles consistently drifts off to the left. So within 50 meters of the starting point they have veered off into another lane.
    I have gone through all the settings and I cannot find anything that makes a difference. I even tried disabling as many components as possible, including damage.

    Anyone have any ideas? I basically want the cars to follow a straight path.

    And thank you Edy for the excellent plugin!

    cheers!
     
  29. cl9

    cl9

    Joined:
    May 31, 2013
    Posts:
    417

    This is fantastic news. How are the tires working with banked curves? Also, will mesh tires need to be constructed in a particular way?

    (I've encountered strange issues with another car physics package where the wheels fall through the mesh colliders)

    Do you plan to add more vehicles, such as an F1 racer?

    Also, will you have an alpha or beta testing program in the coming months for those of us already with the asset and GIT access wanting to try the new features?

    Thanks
     
  30. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    THat picture is hot. Can´t whait for testing the demo!!! And what yo say in teh text is also very promissing!!!
     
  31. Jeremy_Keen

    Jeremy_Keen

    Joined:
    Dec 28, 2013
    Posts:
    2
    Hi Edy - I get this error when I try and PM you: "Edy has exceeded their stored private messages quota and cannot accept further messages until they clear some space."

    Anyway, I am after the c# files - I've sent you an email with my order number.

    Thanks,
    Jeremy
     
  32. sarim987

    sarim987

    Joined:
    Feb 13, 2014
    Posts:
    7
    Can someone please help? im a little desperate here.
     
  33. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    @Edy couple questions/issues:
    1) cannot seem to get any smoke/sand/skidmarks to appear, even on your prefabs, and even when the "always draw skidmarks" is checked
    2) car damage does not seem to deform when hitting a terrain collider
     
  34. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    just set the input parameters for your project to whatever controls you are porting to and the scripts handle it internally.
    goto Edit>Project Settings>Input
     
  35. hamyshank

    hamyshank

    Joined:
    Jan 31, 2013
    Posts:
    88
    second email sent for new version... please check your email
     
  36. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    I'm very sorry for the delay. It shouldn't have happened, but for some reason I had completely missed your first email. Maybe I archived it accidentally when using the phone. I've just replied by email.
     
  37. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Please write me to edytado @ gmail.com so I could help you in a more dedicated way.
     
  38. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Thank you for your feedback!

    The tank is a different case. A tank is a kind of flatten cube with a center of mass very close to the floor due to the heavy chassis and engine. Also, the physic for the caterpillar tracks is different. It's just a kind of standard friction. When there is to much lateral inertia, the caterpillar tracks simply slide over the terrain.

    The situation here is that WheelColliders "as-is" are not suitable for any kind of vehicle simulation. That's caused by the implementation of the Wheel inside the version of PhysX used by Unity ( 2.8 ). This implementation hugely increases the lateral tire friction as result of lateral sliding. Thus, no matter how you setup the parameters, there will be a lateral sliding velocity at which the generated forces will roll over the vehicle.

    This is the achievement of my Vehicle Physics package: I've been able to workaround the design flaw in the WheelCollider by dynamically imposing a limit on the force the tires can generate. If you build your tank using my tweaked WheelColliders instead of Unity's default, then you'll be able to simulate them easily.

    There are several factors that might have influence in the steering drift:
    - Position of the WheelColliders and center of mass. WheelColliders at left-right sides must be perfectly symmetrical around the Center of Mass.
    - Distribution of additional masses. For instance, the DriverFrontPivot object that holds the driver view uses a small mass (0.5 Kg) for simulating the head's movement.

    I'd try using the simplest vehicle possible (without any non-essential component) until I get it accelerating in a perfect straight. Then I'd progressively add components verifying where to tweak them if necessary.
     
  39. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Sure. Vehicles have easy parameters for being controlled: steerInput, motorInput, brakeInput... (See the docs for CarControl). You can easily control them no matter the input the values come from.

    1) Ensure that the Skidmarks GameObject has a default transform (position 0, rotation 0, scale 1).
    2) Works fine in the demo scene. Maybe there is a scale applied to your 3D models? Then you should increase the damage multiplier.
     
  40. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    1) what is calling this g.o.? it is never created into the hierarchy as an instantiated go.
    2) scale does not affect terrain colliders as far as i can tell. it just has resolution to determine size.

    could i email you directly the game link so you could see it live?
     
    Last edited: Mar 11, 2014
  41. donchen

    donchen

    Joined:
    May 27, 2013
    Posts:
    4
    Hi Edy,

    Thanks for your excellent work.
    I am using your car engine to make a game, but now I have a problem.
    I want to load car dynamically from prefab, and I use the code like that to add scripts:
    CarWheel CarWheelRL = colRearLeftObj.AddComponent<CarWheel> () as CarWheel;
    CarWheel CarWheelFR = colFrontRightObj.AddComponent<CarWheel> () as CarWheel;
    CarWheel CarWheelFL = colFrontLeftObj.AddComponent<CarWheel> () as CarWheel;
    CarWheel CarWheelRR = colRearRightObj.AddComponent<CarWheel> () as CarWheel;

    CarAntiRollBar antiRollBarF = SelectedCar.AddComponent<CarAntiRollBar> ();
    antiRollBarF.WheelL = colFrontLeftObj.GetComponent<WheelCollider> () as WheelCollider;
    antiRollBarF.WheelR = colFrontRightObj.GetComponent<WheelCollider> () as WheelCollider;

    CarAntiRollBar antiRollBarR = SelectedCar.AddComponent<CarAntiRollBar> ();
    antiRollBarR.WheelL = colRearLeftObj.GetComponent<WheelCollider> () as WheelCollider;
    antiRollBarR.WheelR = colRearRightObj.GetComponent<WheelCollider> () as WheelCollider;
    antiRollBarR.AntiRoll = 5000;
    CarControl cc = SelectedCar.AddComponent<CarControl> ();


    I use "Pickup Truck" from the demo to test. I remove the CarWheel script on the WheelFL object, and add the script by the code:
    CarWheel CarWheelRL = colRearLeftObj.AddComponent<CarWheel> () as CarWheel;
    But weirdly the colRearLeftObj became null(I am pretty sure I have assign the WheelFL gameObject to it).
    And more weirdly, when I add the CarWheel script back the the WheelFL and run the game(I called it "new Pickup Truck"), the car didn't show up.
    I use the same code to Instantiate "Pickup Truck" and "new Pickup Truck", the "Pickup Truck" can show up and the "new Pickup Truck" can not, but they should be the same prefab!
    Can you help me to figure it out? Or do you have a solution to instantiate prefab from a pure prefab and add scripts by the code?
     
  42. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    HI, I had problem with timescale, time slow. Maybe I made some mistakes and now it doesn't react to t key. Though I got back the old carmain.js but it didn't work.
    Can you tell me wich script is related to time slow except the carmain.js?
     
  43. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    @donchen
    if you are going to use prefabs you might as well make the prefab complete and then instantiate it. kinda defeats the purpose to make a prefab and then dynamically load so many scripts onto it, when you can just assign them to the prefab itself and just load it all there. i don't mean to sound rude, but if you want i can show you how if you PM me.
     
  44. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    1) ok, i have the skidmarks in scene, no transforms, all zero'd. made sure that the carvisuals script has access and finds it correctly. still no instances of the marks appear when they should
    2) i added my own damage system to deal with falling from a set height, but still ramming straight into a terrain collider does not register with the cardamage.js script. no deforms, no impact sound.


    EDIT: it has to do with the physics material applied to a meshcollider. even the same material applied to a terrain collider produces skidmarks, but *any* physics material applied to my track mesh colliders causes the skidmarks not to appear, and all sounds to assume that the surface is not a hard surface. what do i do to convince the scripts that the track is a hard surface?
     
    Last edited: Mar 21, 2014
  45. NextGen Racing

    NextGen Racing

    Joined:
    Feb 8, 2014
    Posts:
    10
    Hey all,

    Just to inform you, since it's car/simulator related could be really helpful for your car development, I've been producing the famous NGRS Tracks Pack, who had a lot of success in another simulator for 3 years now. I decided to produce it for Unity here you go with a lot of FPS efficiency 3D advanced optimized techniques to allow playing it on Mobiles or Smart-phones.

    Please give a look at it feedback me with your thoughts. It's cheap considering the skills you need to produce such 3D worlds.

    @Edy, I would be happy if we could collaborate release some amazing racing/city tracks for your awesome simulator. Please check it PM me, if you want to increase the value of your amazing package ! ;)
     
  46. Tecknowolf01

    Tecknowolf01

    Joined:
    Oct 31, 2012
    Posts:
    49
    I tried but failed to read the whole 20 pages, what is the trick to adjusting the settings to getting rid of the low gravity like reactions when you encounter jumps and bumps. Every time I hit one, the vehicle flies much longer then I would like.
    Thanks for any help!
     
  47. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Ok, I see. Actually a surface is considered "hard surface" when there's no physic material on it. You can change this behavior by rewriting the functions IsHardSurface and IsStaticSurface at CarVisuals.
    • "IsHardSurface" means that tire skid sounds and smoke will be generated (this includes other vehicle's bodies and other non-static scenery objects as well).
    • "IsStaticSurface" means that the object won't move, so it's suitable to draw skidmarks on it.
    You can rewrite those two functions for matching your project's conditions. You could define the type of surface based on collider's name or object's tags, for example.

    CarMain.js is the only script in Edy's Vehicle Physics that modifies the time scale.

    You can add additional acceleration downwards. Add:

    Code (csharp):
    1. rigidbody.AddForce (-2.0 * Vector3.up, ForceMode.Acceleration);
    at the FixedUpdate function. Note that this will modify the friction, handling and speed of the vehicle due to the extra downforce, so you'd want to apply it only when the vehicle is in the air (< 2 wheels contacting the ground).
     
  48. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    Hey! Thank you for the information! Do you have maps of the tracks? A kind of satellite or map view of them? I'm curious because I haven't seen a single straight line in any of the available screenshots (only a small portion of one at the Atzara picture). I believe that a map view of the tracks would help your customers to better evaluate your package.

    Actually I'm looking forward to collaborate with someone in order to renew the scenery of my package, specially for the next major version I'm working on. I already have a list of features on what I would like include on it, even have drawn some drafts. Please write me to edytado @ gmail.com and we'll talk about it! :)
     
  49. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,923
    I'm looking for having it ready for Unity 5 :)

    My package works perfect on all situations. In banked curves the response is exactly as with any real vehicle. I haven't ever seen any issue like that. As long as the colliders are continuous, everything works fine.

    I'm looking forward to collaborate with a 3D artist so I could renew the scenery and include new vehicles. If you know somebody that could be interested, please let me know!

    I haven't decided yet. For now, I'm focusing on completing a preliminary version of the package and a set of basic resources (vehicle + sounds + art). The core design is completed, so now I'm writing and testing the core components. I'll try to follow the Unity 5 schedule, so I may open a beta program depending on how's the progress going.

    Sometimes I find myself spending hours just riding the vehicles :p
     
  50. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    i've been making my own derby/racing game and have many different types of vehicles ready. i kind of need the other end of the spectrum because i don't know how their numbers should work (e.g. torque and friction, etc). want to collaborate?
     
    Last edited: Mar 27, 2014
unityunity