- Home /
CircleCollider2D falling through edgeCollider2D when flipping?
Hi! Im making a 2D car game where the player can flip when hitting a object, but Im having trouble with my flip code. It works about 80% of time, but sometimes the car falls into the ground and gets stuck. Any ideas how to fix this or better ways to flip the car?
Here is the code i currently use to flip the car:
public void Flip()
{
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
facingLeft = !facingLeft;
// dir is used by the wheelJoint2D motor to set direction
dir *= -1;
rb.velocity = -rb.velocity;
motorBack.motorSpeed = -motorBack.motorSpeed;
Debug.Log ("Flip!");
}
Thank you for any advice!
Comment
Your answer
Follow this Question
Related Questions
Why my instantiated 3d text is flipped? 5 Answers
Mirroring texture inside GUI.Button 0 Answers
How to flip based on x pos properly? 1 Answer
Flip 2D object on X axis because of a moving target. 1 Answer