- Home /
how do i put a max to rigidbody.AddRelativeTorque
hey im trying to simulate a plane, but when i try to make it rotate it starts to go faster and faster(i know the AddRelativeTorque does that), but i want to add a max and i cant think of a way to do this. here is the code i used:
@HideInInspector
var xRotation : float;
@HideInInspector
var yRotation : float;
@HideInInspector
var zRotation : float;
var maxRotation : float = 7;
var rotSensibility : float = 7;
function Update(){
xRotation = Input.GetAxis("Vertical") * rotSensibility * Time.deltaTime;
yRotation = Input.GetAxis("Horizontal") * rotSensibility * Time.deltaTime;
zRotation = Input.GetAxis("Roll") * rotSensibility * Time.deltaTime;
rigidbody.AddRelativeTorque(xRotation, yRotation, zRotation);
if (Input.GetAxis("Horizontal") == 0){
rigidbody.AddRelativeTorque(xRotation, 0, zRotation);
}
if (Input.GetAxis("Vertical") == 0){
rigidbody.AddRelativeTorque(0, yRotation, zRotation);
}
if (Input.GetAxis("Vertical") == 0){
rigidbody.AddRelativeTorque(xRotation, yRotation, 0);
}
}
Answer by Karsnen_2 · Jan 15, 2013 at 02:31 PM
I am not sure of what you mean by 'put a max to Rigidbody.AddRelativeTorque'.
Whatever you might as the highest optimal speed on the gameplay is the max. What You See is What You Need. So from you code above, you have used
if (Input.GetAxis("Vertical") == 0)
twice and no matter what input you give in,
rigidbody.AddRelativeTorque
is going to run twice as you called it twice. You might have to consider to it.
As for you, try to adjust rotSensibility
as much as possible to get the maximum you think you need. Then just stop there. It is your MAXIMUM.
No Problem if you were able to find the solution. Dude, can you tick the answer if it had helped to solve your problem.
Your answer
Follow this Question
Related Questions
Rigid body rotation question 1 Answer
Camera rotation around player while following. 6 Answers
Min, Max Rotation Help 2 Answers
Rotate.around to specific point 1 Answer
LookAt once 0 Answers