Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

[Solved]Why doesn't this Rigidbody.AddForce work the way I tell it to?

$
0
0
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); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>