- Home /
[Solved]Why doesn't this Rigidbody.AddForce work the way I tell it to?
Ok so I have this space ship that has thrusters at the front to control its direction by applying a force from the specific position of the thruster using Rigidbody.AddForceAtPosition. However I can only get the thrusters to work on one direction. I cant get both to work. Can you help? More details below.
Here the Code to better explain.
// This uses the mouse Y axis as the input which is the mevert float here.
// The problem is that both don't work only one does, the first one here which adds a force upwards. If I delete the upwards one then the downward one works but not together. It cant be the input because I checked using a bool and also it works alone.
if(mvert > 0.0f) {
vThrust = true;
for(int t = 0; t < thrustersF.Length; t++){
rigb.AddForceAtPosition(Vector3.up * turnSpeed, thrustersF[t].position);
}
if(mvert < 0.0f) {
for(int u = 0; u < thrustersFU.Length; u++){
rigb.AddForceAtPosition(Vector3.down * turnSpeed, thrustersFU[u].position);
}
}
}
Comment
Best Answer
Answer by pacific00 · Aug 21, 2014 at 05:42 AM
cos the second if statement is inside the first if statement.. and it never gets satisfied..
O$$anonymous$$G!!!! I'm a retard.
Thanks for making me look bad man. :)
Your answer
Follow this Question
Related Questions
Prevent Rigidbody From Rotating 3 Answers
Directional rolling a ball ( upwards / left only ) 0 Answers
Why can't i addforce to a rigidbody? 2 Answers
Rigidbody movement conflict? 1 Answer