Question by
Acdrybones · Jul 26, 2018 at 08:30 AM ·
rigidbodytransformrotate
Turning faster right than left when using Rotate?
I have the magnitude modifying the turn speed, and another configurable turn speed thrown in the equation for configging purposes. Anyways, whenever I tested it out I found that my ship moved almost twice as fast when moving right than left, very odd.
void FixedUpdate ()
{
//Moves forward based on throttle position
if (Input.GetKey(KeyCode.W) && Throttle < 100)
{
Throttle += 12 * Time.deltaTime;
}
if (Input.GetKey(KeyCode.S) && Throttle > 0)
{
Throttle -= 12 * Time.deltaTime;
}
RB.AddForce(transform.forward * Throttle / 35 * EnginePower);
//Turns left or right if moving forward
if (Input.GetKey(KeyCode.A) && Knots > 5f)
{
Ship.Rotate(0, Knots / 10 * -TurnSpeed * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.D) && Knots > 5f)
{
Ship.Rotate(0, Knots / 10 * TurnSpeed * Time.deltaTime, 0);
}
//Calculate speed
Knots = RB.velocity.magnitude;
}
Thanks.
Comment
Answer by lucadome · Jul 28, 2018 at 10:37 PM
Try using the Rotate function only with 1 parameter:
if (Input.GetKey(KeyCode.A) && Knots > 5f)
{
Ship.Rotate(Knots / 10 * -TurnSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D) && Knots > 5f)
{
Ship.Rotate(Knots / 10 * TurnSpeed * Time.deltaTime);
}
Your answer
Follow this Question
Related Questions
when trying to rotate, the object transforming itself 0 Answers
Rigidbody2D figits when pushed against an object. 0 Answers
Rotating an object with VR controller 1 Answer
Multiplayer Ragdoll not synchronizing! 1 Answer
Move Single Bone With Script? 0 Answers