Can someone help me with my code here.
I am doing a 2D car racing game. When car goes off the road onto the grass it’s speed goes from 10 to 3. I have successfully been able to make that happen. But now when the car goes from the grass into the mud it’s speed should go from 3 to 1. This code I am not able to implement. Could someone help me with this?
Is my code wrong or is it because I have two trigger on top of each other?
void OnTriggerStay(Collider other)
{
if(other.tag == "Grass")
{
speed = grassSpeed;
if (other.tag == "Mud")
{
speed = mudSpeed;
}
}
}