Hi guys
I’ve a problem with the following script, there are an array of “if else” because for every sensor true, my car turn over direction.
When the centersensor is true the float motor will be negative for reverse turn, but is not working.
I’ve try with a debug and it’s work fine, so I think that the problem is the float motor that is in the end of else condition.
If I modify the else motor with negative it’s work fine, but I want negative only if centersensor is true.
Can you help me?
THK
else if (rightsensor == true)
{
motor = 1f;
steering = -25;
}
else if (centersensor==true)
{
steering = -25;
motor = -maxMotorTorque * Time.deltaTime * 10;
}
else if (rightsensor == true && rightsensorangle == true)
{
steering = -25;
}
else
steering = (relativeVectore.x / relativeVectore.magnitude) * maxSteeringAngle;
motor=maxMotorTorque* Time.deltaTime*10;