Created
December 28, 2017 22:18
-
-
Save augustoerico/13ab33914726953df20d6b9fe4efc148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class CarMovement : MonoBehaviour { | |
public WheelCollider rl = null; | |
public WheelCollider rr = null; | |
public WheelCollider fl = null; | |
public WheelCollider fr = null; | |
public float torque = 10.0f; | |
public float brakeStrength = 5.0f; | |
public float steering = 10.0f; | |
void Update () { | |
float acceleration = Input.GetAxis ("Vertical") * torque; | |
float steer = Input.GetAxis ("Horizontal"); | |
Debug.Log (acceleration); | |
rl.motorTorque = acceleration; | |
rr.motorTorque = acceleration; | |
fl.steerAngle = steer * steering; | |
fr.steerAngle = steer * steering; | |
/*if (acceleration > 0.0f) { | |
rl.motorTorque = acceleration * torque; | |
rr.motorTorque = acceleration * torque; | |
} else if (acceleration < 0.0f) { | |
rl.brakeTorque = brakeStrength; | |
rr.brakeTorque = brakeStrength; | |
} else { | |
rl.brakeTorque = 0; | |
rr.brakeTorque = 0; | |
}*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment