Search Unity

basic car physics

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

  1. lugrana88

    lugrana88

    Joined:
    May 23, 2011
    Posts:
    71
    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:
    71
    never?!?!
     
  3. snortop

    snortop

    Joined:
    Dec 16, 2011
    Posts:
    194