- Home /
Rigidbody acting different on two different objects
Hey guys, I'm having a weird problem.
Okay, I just have a rigidbody with a script that does AddRelativeTorque. Okay, well here's my issue.
I have two objects (old spaceship and new spaceship).
Old Spaceship - Controls work exactly how I want (Arcade like controls). New Spaceship - (Copied script + Rigidbody and pasted to new ship).
Old Spaceship - works exactly how I like. New Spaceship - It's as if it's ignoring all my Drag and Angular drag and spins like a billion miles per hour.
Rigidbody Info:
Mass = 10. Drag = 1 Angular Drag = 2. Interpolate= Interpolate.
VIDEO BELOW
Not that it will really help, because it shouldn't matter because it's pretty generic. But here it is anyways... I don't see what could possibly make it work different for a different model only.
There's literally nothing different whatsoever, it's only a different model. But here's the code. $$anonymous$$aybe there's something in there that could explain why just a model would react different do it that I'm just not seeing.
public float speed;
public float sideThrusterForce;
public float yawSpeed;
public float pitchSpeed;
public Rigidbody myRigid;
float decelerationTime = 1.0f;
private bool airBrakes;
private Health health;
void Start(){
health = GetComponent<Health> ();
Cursor.lockState = CursorLock$$anonymous$$ode.Confined;
Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
Cursor.visible = false;
}
void OnCollisionEnter(Collision col){
health.DoDamage (10);
}
void FixedUpdate () {
myRigid.velocity = Vector3.Clamp$$anonymous$$agnitude (myRigid.velocity, speed);
if (!airBrakes) {
myRigid.AddRelativeForce (Vector3.forward * speed);
}
if (airBrakes) {
myRigid.AddRelativeForce (-Vector3.forward * speed);
}
myRigid.AddRelativeTorque ((Input.GetAxis ("$$anonymous$$ouse Y")) * yawSpeed, 0, (-Input.GetAxis ("$$anonymous$$ouse X")) * pitchSpeed);
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.A)) {
myRigid.AddRelativeTorque(0,(Input.GetAxis("Horizontal") * yawSpeed * 2),0);
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.D)) {
myRigid.AddRelativeTorque(0,(Input.GetAxis("Horizontal") * yawSpeed * 2),0);
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.W)) {
myRigid.AddRelativeForce (Vector3.forward * speed * 3);
}
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.S)) {
airBrakes = true;
}
if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.S)) {
airBrakes = false;
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.Q)) {
myRigid.AddRelativeForce (Vector3.left * sideThrusterForce);
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.E)) {
myRigid.AddRelativeForce (Vector3.right * sideThrusterForce);
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.Space)) {
myRigid.AddRelativeForce (Vector3.up * sideThrusterForce);
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.C)) {
myRigid.AddRelativeForce (Vector3.down * sideThrusterForce);
}
}
}
Answer by N1warhead · Mar 26, 2017 at 11:30 AM
Figured it out finally guys... I tried to use a Capsule Collider and apparently it messes with the way the physics work, so I did a Convex Mesh collider and now it works just right...
Not sure if that's a bug or normal. But it works lol.