- Home /
Steering left different value than steering right
hello, i have a little problem with my unity script. im using a slider in settings.cs to modify the speed and steering of my cart. They are both working, however when i press debug.log it shows that left steers less fast than right. Example: left -7.0f middle 0 right 9.0f it also occurs with other values such as -3,8 0 5,8.
i want it to be the same for both sides, so 8 0 8 or 5 0 5 and so on..
in my test situation i removed all objects/script and let left and right steer exact the same. result: 7 0 9, 6 0 8 so even if left and right are the same, left is less powerfull?
if ( steer > 0) { direction += (steer + steerpower) * Vector3.right; transform.Translate( direction * Time.deltaTime );
}
if ( steer < 0)
{
direction += (steer + steerpower) * Vector3.right ;
transform.Translate( direction * Time.deltaTime );
}
Debug.Log(direction);
the code im using to go left is Vector3.left, in the above example i showed that the same things have different values.
Answer by Statement · Mar 28, 2011 at 12:51 PM
Because you're adding steerpower and not multiplying it. Besides, that if-check is completely redundant.
direction += steer * steerpower * Vector3.right;
transform.Translate( direction * Time.deltaTime );
Debug.Log(direction);
Consider if steer is -4 and steerpower is 5.
-4 + 5 = 1.
-4 * 5 = -20.
That is, with -4 steer you'd still go right if you were adding the numbers. With multiplication you'd go left (as expected).
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Shortest distance from a point to a vector 2 Answers
Trouble with Camera Rotation Math 2 Answers
Issue with seed-based generation [C#] 3 Answers