I noticed when my car is moving backwards, and I’m trying to turn at the same time, the car is not turning in the direction I’m expecting it to turn. So I added some conditions: if the moving amount is positive, then the steering amount is negative:
void Update()
{
float steerAmount = Input.GetAxis(“Horizontal”) * _steer_speed;
float moveAmount = Input.GetAxis(“Vertical”) * _speed;
transform.Translate(0, moveAmount, 0);
if (moveAmount < 0)
{
transform.Rotate(0, 0, steerAmount);
}
else
{
transform.Rotate(0, 0, -steerAmount);
}
}
Let me guess, it’s only moving up and down the y axis?
That’d be because of the:
transform.Translate(0, moveAmount, 0);
I’d suggest you try to rotate first and then move forward/back, instead of transform.Translate on a the same straight axis. I believe you’d find the code in the Drift Driving Quest in Skill Builder Season 2 package. It might also be part of the new 2d course, but I haven’t looked at that one yet.
No, they said what it’s doing - it’s turning the opposite direction when backing up. I actually came here to see if anyone else noticed this too, and implemented a similar fix to my code - reverse the direction of rotation if the car is backing up.
I saw that too. If the driver reverses and turns the steering left it should follow the tyre (tire US). Forward works however.