I am creating a script to control a bike, but am not having success, I tried with the script below, but when I change the property centerofmass the update, the bike is swaying from side to side and never stops.
Any suggestions?
Script
public class bike : MonoBehaviour {
public WheelCollider rodafrente;
public WheelCollider rodatraz;
public int motorpower = 30;
public int volant = 20;
// Update is called once per frame
void Update () {
float inputX;
float inputY;
//inputX = Input.acceleration.y;
inputX = Input.GetAxis("Horizontal");
inputY = Input.GetAxis("Vertical");
rodatraz.motorTorque = motorpower*inputY;
rodafrente.steerAngle = volant*inputX;
if (Input.GetKey("space")) {
rodafrente.brakeTorque = rodatraz.brakeTorque = 10;
rodafrente.brakeTorque = rodatraz.brakeTorque = 10;
}
else {
rodafrente.brakeTorque = rodatraz.brakeTorque = 0;
rodafrente.brakeTorque = rodatraz.brakeTorque = 0;
}
rigidbody.centerOfMass = new Vector3(inputX, 0, 0);
}
}