Search Unity

  1. 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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

basic car physics

Discussion in 'Scripting' started by lugrana88, Feb 7, 2013.

  1. lugrana88

    lugrana88

    Joined:
    May 23, 2011
    Posts:
    68
    Hello to all you guys!
    I made this script but I have a problem:

    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. var RuotaAD : WheelCollider;
    5. var RuotaAS : WheelCollider;
    6. var RuotaPD : WheelCollider;
    7. var RuotaPS : WheelCollider;
    8. var maxTorque : float = 40;
    9.  
    10.  
    11. function Start () {
    12.     rigidbody.centerOfMass.y = -0.0001;
    13. }
    14.  
    15. function FixedUpdate ()
    16. {
    17.     RuotaPD.motorTorque = maxTorque * Input.GetAxis("Vertical");   
    18.     RuotaPS.motorTorque = maxTorque * Input.GetAxis("Vertical");   
    19.     RuotaAD.steerAngle = 10 * Input.GetAxis("Horizontal");
    20.     RuotaAS.steerAngle = 10 * Input.GetAxis("Horizontal");
    21.  
    22. }
    23.  

    car loses grip when running and just takes a bit of speed
    running but on two wheels, not four.
    and then again increasing the speed, rolls!
    also changing the mass of the rigidbody is the same.

    help me please!
    thank you very much!
     
  2. lugrana88

    lugrana88

    Joined:
    May 23, 2011
    Posts:
    68
    never?!?!
     
  3. snortop

    snortop

    Joined:
    Dec 16, 2011
    Posts:
    194
unityunity