I’m spawning cars with colliders. As soon as the player loses, the trigger on the car’s collider is turned off and it starts colliding with other cars/walls.
My problem is after it reaches the left/right end of the screen where I placed a wall with a collider, it gets stuck. I wanted it to bounce off to a random direction and rotate to make it look like it’s in space.
I have this code on my car object:
void Update()
{
if (GameManager.SharedInstance.GameOver)
{
col.isTrigger = false;
}
}
void FixedUpdate()
{
rb.velocity = new Vector2(speed, 0);
//for cars going to the left, I set it to --> rb.velocity = new Vector2(-speed, 0)
}
I also learned that all physics should be placed on FixedUpdate, any idea on how to do this? Any help would be appreciated! Thank you!