Search Unity

Edy's Vehicle Physics - official thread

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

  1. NorthernVisionStudio

    NorthernVisionStudio

    Joined:
    Oct 18, 2013
    Posts:
    60
    Hi Edy and everyone:

    I am one of your happy customers. Thanks for making a nice tool for cars. So, I'm trying to control the position and the rotation in 2D of the car and let the physics do the rest (suspension, etc). This is for the purposes of scripting movement. Where I am stuck, and would appreciate a hint, is to roll the wheels. It seems there is some 'fighting back' and reverse wheel rolling (as the car slides forward) when I apply a simple push to the car. But this depends on the car settings, which are directly related to your code.

    Rigidbody carBody = carControl.gameObject.GetComponent<Rigidbody>();
    carBody.MovePosition(carBody.position + new Vector3(0,0,.2f) * Time.deltaTime);
     
  2. Kognitive

    Kognitive

    Joined:
    Mar 14, 2014
    Posts:
    7
    Hi Edy. First time posting in your thread so I'd like to congratulate you on a fantastic product. I'm very happy with the car handling I can produce with your system.

    The only real problem I have is probably not even related to your code but something to do with Unity itself. I cannot work out how to get the terrain to accept a physic material and as a result the car handles the same on the terrain as it does on the track surface. I understand that your wheel collider physics treats a normal collider that has no physic material assigned to it as a road surface which is fine, and I think your wheel collider physics adjusts the wheel friction based on other physic materials if they are present. So the problem here is that my terrain acts like a road surface because any physic material assigned to it is apparently being ignored by Unity. Have you or anyone else got any ideas on how to fix this problem? Is anyone able to get different wheel physics behaviour on the terrain? Any help would be greatly appreciated.
     
  3. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    page right before this one answers that
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Use AddForce with ForceMode.VelocityChange instead of MovePosition. You could monitor the rigidbody.position value and apply the velocities accordingly. Try this script added to any vehicle:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class test : MonoBehaviour
    5.     {
    6.     void FixedUpdate ()
    7.         {
    8.         if (Input.GetKey(KeyCode.F))
    9.             rigidbody.AddForce(transform.forward * 0.2f, ForceMode.VelocityChange);
    10.         }
    11.     }
    12.  
    Pressing the F key modifies the velocity. If you want to keep a constant velocity you should monitor rigidbody.velocity as well, and apply the velocity change accordingly.


    Thank you!! :)

    This question also addresses a different problem not mentioned earlier. Since some Unity 4.x version (maybe 4.2) the terrain collider stopped accepting physic materials. I asked Unity and got a messy explanation about that PhysX doesn't actually uses the physic material internally, so they decided that terrain colliders would return null when queried for the physic material. I convinced them that there are actual case usage scenarios where the old behavior is clearly an advantage (vehicles) even given that the physic material is ignored by PhysX. I've submitted a bug case several weeks ago. We can expect this behavior to be reverted in future versions.
     
  5. Kognitive

    Kognitive

    Joined:
    Mar 14, 2014
    Posts:
    7

    Thanks Edy. That's both good and bad news I guess. In the meantime is there any kind of workaround? Although I can sometimes adapt scripts to my needs I'm not a programmer so coming up with a full solution is beyond my current capabilities. I did experiment with giving the road surface a physic material with double the friction and changed the car's grip to half so that it was slippy on the terrain but it caused too many other issues.

    So is there any way your wheel colliders can differentiate between the terrain and other surfaces so that a script can be written to assign our own physics parameters to the terrain? Perhaps a script that can be attached to the terrain (similar to the EasyRoads3D terrain ID)? Or is there some other solution?
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That's the issue mentioned by mcconrad that was addressed in the previous page :)
    http://forum.unity3d.com/threads/12...hread/page20?p=1572594&viewfull=1#post1572594

    You could detect the terrain via tags (or any other method of your choice), and ensure that it gets identified as "not hard surface" and "is static".
     
  7. Kognitive

    Kognitive

    Joined:
    Mar 14, 2014
    Posts:
    7
    I did see that post but I don't see a solution there for a non-programmer. I'll certainly have a go though as I enjoy learning, but I'm a little out of my depth. Hopefully when Unity reinstates terrain physics properties it'll just work as its supposed to.

    EDIT: Well that wasn't as hard as I thought :). I just added a Tag to the terrain object and an "if" statement to the IsHardSurface function and it worked! Here's what the function looks like now:

    Code (csharp):
    1. private static function IsHardSurface(col : Collider) : boolean
    2.     {
    3.     if (col.tag != "Terrain")
    4.         {
    5.         return !col.sharedMaterial || col.attachedRigidbody != null;
    6.         }
    7.     }
    Now to work out how to make the terrain more slippy!

    EDIT2: Got that working too! Edited CarWheel.js to detect the terrain tag and added an "else if" statement to add some hard coded values. Will post code later.

    EDIT3: Here's the code I added to CarWheel.js (at line 269. This only works if you've tagged terrain with a tag called "Terrain"):
    Code (csharp):
    1. // "ELSE IF" ADDED TO OVERCOME LACK OF PHYSIC MATERIAL FOR THE TERRAIN
    2.         else if (m_wheelHit.collider.tag == "Terrain") // if there is a tag named "Terrain" on the collider lets adjust the friction curve manually
    3.             {
    4.             m_wheel.forwardFriction.stiffness *= 0.5;
    5.             m_wheel.sidewaysFriction.stiffness *= 0.5;
    6.            
    7.             // Aplicar fuerza de resistencia fuera de la carretera - lets apply resistance force manually (the 0.03 value below is the dynamic friction parameter you can manually set)
    8.  
    9.             wheelV = m_rigidbody.GetPointVelocity(m_wheelHit.point);
    10.             m_rigidbody.AddForceAtPosition(wheelV * wheelV.magnitude * -m_wheelHit.force * 0.03 * 0.001, m_wheelHit.point);
    11.             }
    There may be better ways to do it but so far it works for me. I guess also by adding more of these sections into the script you could define a number of different surface properties using different tag names for different terrains, or collider meshes that don't have a physic material.
     
    Last edited: Apr 4, 2014
  8. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Nice work! That's a perfectly valid solution :)
     
  9. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    So I just bought this script yesterday and I'm trying to get to grips with it now, but I've hit a couple of problems:

    Damage: Don't seem to be able to get this going. I tried the box colliders at first, just to test it out. That didn't work, so I thought maybe my colliders need to be more accurate. So I duplicated parts of my mesh, moved them to the BodyColliders tree and added the mesh collider component, setting it up as the box meshes were. But it still doesn't work. I've tried changing the values and multipliers, but still nothing. All I end up doing is damaging the wheels, not the car itself.

    Edit: just to say I did read about some scale issues with damage and I have already set the scale of my mesh peices before importing to unity.

    One more thing: Aligning the colliders. Are there any tips or tricks to this? Some like align to pivot? I can't seem to get mine aligned perfectly by hand and it's slightly screwing up the rotation animation on the wheels.

    Thanks for reading my essay :D
     
    Last edited: Apr 11, 2014
  10. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    a tip for the wheel pivots: first make sure they are in center of wheel with a modeling program. then in unity select the wheel, and create an empty child object. this will make it at the exact center, then unparent the child object, and drag the wheel into it in hierarchy and that will make the (former) child the wheel's parent. rename it pivot_whateverWheel and use that as the pivot object for the scripts and keep the wheel as the mesh object. the wheel colliders themselves don't need to be perfectly aligned as long as the pivots are, i believe.
     
  11. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    Thanks mcconrad, that's really helpful! I've managed to get sound going, and it's really impressive. So many options to setup, when they all come together it sounds awesome.

    Still not managed to get the damage going though :(
     
  12. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    the damage script itself has a threshold in the inspector that is the minimum amount of damage required before it will deform the meshs. try changing that value up/down till you see deformation. also there are 3 sections in the car damage script that need to be populated with your meshes/nodes:

    the 1st under deform meshes are the things on the car that will be dented, deformed, etc. so the car hood, or the chasis mesh object would go there. the 2nd are deform nodes, which essentially are the wheels, and 3rd are the deform colliders which receive the impact and then use that to deform the actual meshes, so these would be box colliders for like a bus or lower resolution mesh colliders of the main parts of the vehicle.

    also make sure auto-bounce is not on, that automatically fixes all damage the instant it happens.
     
  13. mantekkerz

    mantekkerz

    Joined:
    Dec 24, 2013
    Posts:
    111
    I'm still not able to get the car meshes to deform. I've played with the settings in the inspector, and I'm certain my meshes are setup properly to deform the vehicle. But I only ever end up damaging the wheels and not deforming the body.

    I'm getting a NullReferenceException after playing the game: looks like something to do with the cameras, specifically the mirrors, which are disabled so I'm not sure whats going on there or if that could be affecting this.
     

    Attached Files:

  14. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    well you pretty much need to isolate and eliminate the null references before we can move on since often unity will stop and disable any offending scripts, so any others that rely on them are also broken. if you could copy and paste the error, that would help.
     
  15. Benji-John93

    Benji-John93

    Joined:
    May 2, 2013
    Posts:
    20
    Hey love this package, easy to understand and add your own vehicles ect.
    Only thing in having trouble with and would very much appreciate some help on this is that I'm trying to figure out how I can make a score system so that when the car "drifts" score is given, looking for possibly the simplest way or even a more complex method to do this? Thanks in advance! And great job on this package!
     
  16. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Edy I have a couple questions about the vehicle physics. 1) can you disable and enable the vehicles physics simulation at run time, like to allow a more rigid movement of the vehicles until they collide, and then have the real physics begin to take over and realistically crash the vehicle after an impact? This would be useful to have less intensive kind of stand in where the vehicle follows a pre-set path, then switching back to using the regular physics when crashed or similar situation. And also 2) would it be possible to also simulate the wheels turning as the vehicle moves along the road by a tween's motion along a spline, and perhaps still steer the wheels in the direction of the vehicles movement as if the physics were still in control?

    Thanks ahead of time!
     
  17. BioFan

    BioFan

    Joined:
    Mar 4, 2013
    Posts:
    24
    I'm tempted to get this, but have a question.
    I have a "driver" that's visible, and want her to move as the wheels are turning.
    How easy is it to set it up using this plug in? I've tried reading the documentation but I can't find the specific answer I'm looking for.
    Anyone care to help me? Thank you :)
     
  18. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    depends on if you use IK or not. if you don't have pro or an IK script, then you need to use baked animations, but it is still not that hard. much easier with IK.
     
  19. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Thanks! Simplest method is to read the rigidbody's velocity and look for the sideways velocity. Above a certain threshold you can be sure that the car is drifting. Something like:

    sidewaysVelocity = Mathf.Abs(Vector3.Dot(rigidbody.velocity, transform.right));
    if (sidewaysVelocity > 4.0) { // Surely it's drifting here }

    I would also account for the number of wheels that are touching the ground. It should be >= 2 for ensuring that the vehicle is not rolling over.


    For 1) you could try simply disabling the CarControl script. For 2) in addition to disabling CarControl you have two flags in the CarVisuals script: disableRaycast and disableWheelVisuals. Find the comments on how to use them at the code. About steering the wheels you can modify how the steering is applied in CarVisuals. Look for the function DoWheelPosition.


    Maybe a simpler method that mcconrad proposes would be to have the driver model previously animated by the 3D modeler: from full left, to the center, and full right. Then you could read the actual steering value and set the animation position accordingly. The steering angle is actually used at CarVisuals for rotating the steering wheel. You could take it as example.
     
  20. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    @Edy, is there a (simple) method of changing autobounce to a % bounce? for example, i want to repair damage, but not all damage, only 50% damage. what is the best way to do this?

    or if you are already planning to add this to next release, i can just wait for that.

    thanks!
     
  21. Lllllllllllllll

    Lllllllllllllll

    Joined:
    Apr 25, 2014
    Posts:
    2
    Dear cheezorg,
    How to make car never overtuned? As same as in your game Toon Drive.
    Thank you very much!!
     
  22. Lllllllllllllll

    Lllllllllllllll

    Joined:
    Apr 25, 2014
    Posts:
    2
    Hi Edy
    how to go faster with Nitrogen ?
    Thank you.
     
  23. cheezorg

    cheezorg

    Joined:
    Jun 5, 2008
    Posts:
    394
    I have invisible colliders on the top of the vehicle that make sure it never lands on its roof and gets stuck.
     
  24. Benji-John93

    Benji-John93

    Joined:
    May 2, 2013
    Posts:
    20
    Okay So ive been playing around with this and the control-freak package, and I've ran into some trouble... I've looked at your code in CarMain.js and the acceleration, brake and steering are all "getaxis"

    var steerValue = Mathf.Clamp(Input.GetAxis("Horizontal"), -1, 1);
    var forwardValue = Mathf.Clamp(Input.GetAxis("Vertical"), 0, 1);
    var reverseValue = -1 * Mathf.Clamp(Input.GetAxis("Vertical"), -1, 0);
    var handbrakeValue = Mathf.Clamp(Input.GetAxis("Jump"), 0, 1);

    The problem im having is that i need them to be like:

    Input.GetKeyDown(KeyCode.W) //Up
    Input.GetKeyDown(KeyCode.A) //Left
    Input.GetKeyDown(KeyCode.S) //Down
    Input.GetKeyDown(KeyCode.D) //Right

    Can anyone help me here? i cant continue with my project as im stumped here :(
    Thanks in advance!
     
  25. TViljanen

    TViljanen

    Joined:
    May 5, 2014
    Posts:
    1
    I have the same problem. Can someone comment and advise on how to get this problem solved.

    I'm using Unity 4.3.4f1


     
  26. WhiteThunder94

    WhiteThunder94

    Joined:
    Apr 7, 2014
    Posts:
    6
    Work on Android and iOS device?
     
  27. igor_berezin

    igor_berezin

    Joined:
    May 14, 2014
    Posts:
    1
    Hey, i have a question about the controls with touch for mobile.
    I've been following this whole thread and came out at some point, but the answer was just "switch to mobile controls" in the input manager.
    I did overwrite the input manager file, but can't seem to find any of that option.
    Also can you direct me to where/how is best to make these changes (a touch button for acceleration, a touch button for braking) ?
    I've been trying to modify the carmain.js but get to a whole bunch of other problems.
    Thanks!
     
  28. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    See CarDamage::BounceMesh. This method receives both the actual mesh and the original positions for the vertices. You can rewrite this method for interpolating the positions, or moving the vertices as you need.

    Import the package into an empty project.

    Yes, here are two examples: Android iOS

    You can either rewrite the method that manages the input (CarMain::SendInput) or provide the values from your own scripts to the vehicles via the parameters exposed at CarControl: motorInput, brakeInput, steerInput, handbrakeInput.
     
  29. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Last edited: May 15, 2014
  30. StudioLeaves

    StudioLeaves

    Joined:
    Nov 5, 2013
    Posts:
    2
    1. How can i get the speed value from a car in my c# code?
    2. How can i change the keyboard parameters?
     
  31. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    I bought the asset today and noticed other users comments saying you have c# source code which you can send to those who ask ..I emailed you , im asking .. please send me the c#

    I will send you the invoice from unity if needed, I did quote the ref number of the sale in my email
     
  32. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    1. Use rigidbody.velocity. That's what I'm using for reading the speed that it shown in the dashboard (see CarMain::OnGUI).
    2. Keyboard for all cars is read at the function CarMain::SendInput. Feel free to rewrite or modify it to fit your needs.

    I'm on it, please be patient! Lots of requests :)
     
  33. daeuk

    daeuk

    Joined:
    Mar 3, 2013
    Posts:
    67
    would it be possible that the c# be included on the unity package?
     
  34. DougMcFarlane

    DougMcFarlane

    Joined:
    Apr 25, 2009
    Posts:
    197
    +1!

    I assume just including the C# folders and files would cause issues with compiling, since each command would be duplicated (and / or whatever happens when you combine two languages without using the "Standard Assets" or "Plugins" folder).

    You could simply include a zipped up c# code file so it won't collide.
    Or replace the UnityScript and go exclusively C#, since it's an obviously superior language (do you remember where you were when the great language war of 2014 started?). Kidding, of course. Volatile subject!

    Just bought this yesterday, can't wait to start tinkering.
     
  35. Zini

    Zini

    Joined:
    Oct 28, 2013
    Posts:
    1
    I have the same problem. Any help?

     
  36. CaptainFreedom_

    CaptainFreedom_

    Joined:
    Feb 6, 2014
    Posts:
    1
    Hi,
    I am having problem when using Edy's Vehicle Physics with roads created with Road Architect: Friction seems to be very high when driving on Road Architect roads. In effect the car will only drive up to 50 mph. However - in the same scene - when driving directly on terrain - Edy's car will behave normally - as expected (top speed 90mph).
    I changed roads physics material friction settings but it did not help, in fact it did not have any effect whatsoever on how the car behaved on Road Architect made roads. So I guess it must be something else. Roads created by Easy Roads 3D did not cause this problem.
    Please help :)

    EDIT: Solved it myself. disabled mesh colliders on road objects. working perfectly now
     
    Last edited: May 20, 2014
  37. Wavinator

    Wavinator

    Joined:
    Dec 24, 2013
    Posts:
    79
    Would you consider putting a note or warning on the asset store page about this? You have it in the readme, but as far as I can tell the readme is not accessible until you download the package. I'm new to Unity and didn't know downloading a package could completely wreck a project. I imported this into an existing project just as I've done with almost a dozen others and got a ton of errors (.js camera errors, global game manager and Unity's "Mismatched serialization in the builtin class 'Mesh'" which seems to afflict some older packages) as well as completely lost my terrains. Lucky for me I'm just experimenting so it wasn't a serious loss other than time.

    I see a lot of posts where people are having a great time using this package, the reviews are glowing and I bought on the strength of the excellent demo alone. But the unwary noob can completely lose EVERYTHING! If you added "Note: Must be imported into an empty project" you'd save a lot of frustration.
     
  38. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
    Wavinator : This is something I learned a long time ago on other projects with other assets. Basic rule is never import anything from the asset store into your project, if you do, FIRST MAKE A BACKUP OF YOUR PROJECT! My personal practice is to always import from the asset store into a blank project (I actually have a project simply called 'Asset Store Downloads').

    Edy : Thank you for your asset, I have had hours of fun just driving around :)

    Something that I'm surprised hasn't come up yet : if you set your deform mesh colliders to a layer other than Default, CarVisuals actually sets them to Default. I wrote in some code to remember the layer at Start, then reapply those layers after DoWheelPosition.

    I'm having trouble understanding what I'm seeing in the Wheel telemetry, all I've worked out so far is MotorPerformancePeak changes the rate of acceleration, and ForwardWheelFriction-Grip changes the top speed. If anyone has some kind of look-up table for each of the CarControl variables for different types of cars, that would be awesome.

    Ok, but the main reason I'm posting is I have a problem that I cannot seem to solve. I'm adding in the ability to damage the car by giving CarVisuals positions and forces, for bullet damage and explosion forces (in a GTA style game).

    So in my current test, I'm sending the hit information from a raycast to CarVisuals like this :

    Code (csharp):
    1.  
    2. m_CarVisuals.BulletDamage( hit.point, hit.normal * -bulletForce );
    3.  
    and the function I've added to CarVisuals is :

    Code (csharp):
    1.  
    2. function BulletDamage( point : Vector3, impactVelo : Vector3 )
    3. {
    4.     //Debug.Log( gameObject.name + " HAS BEEN HIT BY A BULLET!" );
    5.    
    6.     m_sumImpactCount++;
    7.     m_sumImpactPosition += transform.TransformPoint( point );
    8.     m_sumImpactVelocity += transform.InverseTransformDirection( impactVelo );
    9.    
    10.     // make sure this gets processed
    11.     m_lastImpactTime = 0;
    12. }
    13.  
    but the mesh doesn't want to deform :(

    From what I can tell, this is all that I need to do for CarDamage ProcessImpacts() to see localImpactPosition and localImpactVelocity, and deform the graphic and collider meshes.

    Can you help me solve this problem so I can deform the meshes by sending a point and a force? Many Thanks.
     
  39. rameshkumar

    rameshkumar

    Joined:
    Aug 5, 2013
    Posts:
    50
    I too got the same error, after that i used time.timescale=0.0001..its working fine

     
  40. bloobie

    bloobie

    Joined:
    Apr 1, 2010
    Posts:
    13
    Hi
    i have some problems setting up the wheels and other stuff
    i created some empty gameobjects an named them pivot_FL, ... an put the wheel mesh in it and linked them to the script
    i only moved and scaled the gameobject to the right position the rear wheels work problery but the front wheels -- you see it on the picture


    http://screencast.com/t/4UIzb1EywX

    an other problem is that the skidmarks work at the front properly but at the rear they overlap in the middle of the car
    http://screencast.com/t/7HPGQqY0Nc

    and the last thin for now is that the steering wheel rotates around an wrong axis --
    i also createt an empty object and put the steeringwheel in it and arranged the empty objects axis to position but in game it rotates around an axis which is in the middle of the car
     
  41. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    almost 2 months and no response. please answer., thanks!
     
  42. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That one was replied long ago, see the post #428 above.

    Sorry everyone, as it seems that I wasn't receiving notifications on new posts. I'll reply the pending questions as soon as I can.
     
  43. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    sorry about that. not only has unity website been ignoring the "stay signed in" featured, but it is no longer sending emails about replies. in fact, i didn't even get this one; i had to check in manually (and sign in AGAIN).
     
  44. Arsinx

    Arsinx

    Joined:
    Apr 14, 2014
    Posts:
    55
    Hi
    Ive made a formula one racing game, and everything is working fine but im getting a weird bug. The Car automatically moves to the left at very slow and very fast speeds for some reasons. Any thoughts on what make it behave like this?
     
  45. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    how to fix this error?

    UnityException: Input Axis Sideways is not setup.
    To change the input settings use: Edit -> Project Settings -> Input
    CamSmoothLookAt.LateUpdate () (at Assets/EdyVehiclePhysics/CameraScripts/CamSmoothLookAt.js:68)
     
  46. msd1357

    msd1357

    Joined:
    Jul 7, 2014
    Posts:
    8
    Hello.

    I made a simple game with a train and a vehicle. It works on PC platform and I can run it on an android mobile. But I have a basic problem and I don’t know how I could implement WASD keys on a touch screen mobile.

    I place 4 GUI Texture objects on screen. I think that I should call a Edy’s Vehicle Physics method in MouseDown to do movement in all of the WASD keys, but I don’t know which method or action I should call. or I’m in a wrong way and should use another way? Please help me.

    Thanks…
     
    mdv73rus likes this.
  47. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    any new info on this? the asset store version hasn't been updated in 2 years.
     
  48. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    My next Vehicle Physics product will be 100% C#. For the actual package, I prefer to keep it this way as "bonus" for customers.


    Import the package into an empty project. Note that the category for this product in the store is "Complete Projects".


    My apologies. Will do at the next update. I guessed that belonging to the category "Complete Projects" in the store was a enough, but the note will be useful as well.


    Mesh colliders are moved to/from the layer "Ignore Raycast" for preventing self-hits when calculating the wheel's position. I'm now considering the starting layer in my actual developments.


    All telemetry values are detailed here:
    http://projects.edy.es/trac/edy_vehicle-physics/wiki/CarTelemetry


    Try scaling the values until you see some result (multiply the force per 10, 100...). Usually OnCollisionEnter and OnCollisionStay report many contacts per each impact, so all of them are leveraged into something that matches the expected result. Thus, a single small hit as you're trying may not have visible results.


    CarVisuals expect the wheel meshes to have certain properties:
    - Object's origin (0,0,0) located at the center of the wheel. It's the point around it spins and steers.
    - "Forward" orientation for the meshes should be +Z.

    The script will simulate the wheels' spin by rotating them around the X axis. The steer is simulated by rotating the pivot object (the parent of the wheel) around the Y axis.

    If your wheel meshes don't match these requirements, you must either edit them with a 3D modelling tool, or create empty gameobjects at the required roles (pivot, wheel) and place your wheel mesh as child of the "wheel" gameobject. They apply the proper correction to the mesh's transform.

    An easier way is to use any of the included vehicles as starting point. Instead of replace the wheel mesh objects, place your wheels as child of each existing wheel. Then find the correct transform for it. You can then disable or remove the MeshRenderer component of the original wheel.
     
  49. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    When approaching the top speed the wheels are applying full force against the aerodynamic drag. If the application points are misaligned, even by a fraction of unit, there will be a torque effect.

    Another possible cause is the mass distribution. If the center of mass is not perfectly centered and aligned with the wheels, then one of the wheels will apply more force than the other, thus creating the effect.

    Finally, the head movement is simulated with a small mass linked to a joint. Try disabling/removing this gameobject (DriverFrontPivot) to check out if there's some change in the behavior.


    Close Unity and use the file explorer for moving the file InputManager from Assets to ProjectSettings.


    User input is handled at the method CarMain.SendInput. You can rewrite it to fit your needs.


    Latest version (April 2014) is available at the project's page via package download and GIT repository. You can request access by sending me an email (edytado@gmail.com) with your invoice number.
     
  50. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Oh, I forgot! The new Vehicle Physics I'm talking about will be a different product. It's a completely new system designed and implemented from the scratch featuring a realistic simulation from the tire friction up to the engine and drivetrain. It's not compatible with the actual package. For now, I can show you this basic prototype:

    http://www.edy.es/unity/prototype/webplayer.html

    This demo tests the tire friction model only. It's based on a previous iteration of the development. The actual state of the simulation is much more improved. I expect the package to be released (or at least enter the beta stage) around september-october.