Exemplo n.º 1
0
 void FixedUpdate()
 {
     if (gameObject.rigidbody.velocity.magnitude < 5)
     {
         inCollision = true;
     }
     if (runnable && inCollision)
     {
         if (Input.GetAxis("Vertical") > 0)
         {
             if (!inChaotic)
             {
                 gameObject.rigidbody.AddRelativeForce(0, 0, 30000);
                 if (c != null)
                 {
                     c.moveCarForward(carID);
                 }
             }
             else
             {
                 gameObject.rigidbody.AddRelativeForce(0, 0, -30000);
                 if (c != null)
                 {
                     c.moveCarBackward(carID);
                 }
             }
             //networkView.RPC("moveForward",RPCMode.All,carID);
         }
         else if (Input.GetAxis("Vertical") < 0)
         {
             if (!inChaotic)
             {
                 gameObject.rigidbody.AddRelativeForce(0, 0, -30000);
                 if (c != null)
                 {
                     c.moveCarBackward(carID);
                 }
             }
             else
             {
                 gameObject.rigidbody.AddRelativeForce(0, 0, 30000);
                 if (c != null)
                 {
                     c.moveCarForward(carID);
                 }
             }
             //networkView.RPC("moveBackward",RPCMode.All,carID);
         }
         if (Input.GetAxis("Horizontal") > 0)
         {
             if (!inChaotic)
             {
                 gameObject.transform.Rotate(0, 1, 0);
                 if (c != null)
                 {
                     c.rotateCarRight(carID);
                 }
             }
             else
             {
                 gameObject.transform.Rotate(0, -1, 0);
                 if (c != null)
                 {
                     c.rotateCarLeft(carID);
                 }
             }
             //networkView.RPC("rotateLeft",RPCMode.All,carID);
         }
         else if (Input.GetAxis("Horizontal") < 0)
         {
             if (!inChaotic)
             {
                 gameObject.transform.Rotate(0, -1, 0);
                 if (c != null)
                 {
                     c.rotateCarLeft(carID);
                 }
             }
             else
             {
                 gameObject.transform.Rotate(0, 1, 0);
                 if (c != null)
                 {
                     c.rotateCarRight(carID);
                 }
             }
             //networkView.RPC("rotateRight",RPCMode.All,carID);
         }
     }
 }