Stop ball sprite passes through the wall?
I am new to unity. Learning 2d games.
I created a ball sprite and gave it properties of Rigidbody 2D and CircularCollider 2D and gave the material properties to bounce. Added a floor and ceiling sprites and tried both edge and box Colliders but when the ball start to bounce fast between floor and ceiling it just moving through ceiling/floor. How to make the ball sprite remain inside the bounds of the wall ?
Answer by MelvMay · Dec 02, 2015 at 12:05 PM
If the Rigidbody2D is moving very fast and/or the collider attached to it is very small compared to the other colliders it may contact then it will pass through it.
In this circumstance, you should use continuous collision mode.
How can i make the collider large, by increasing the radius of collider will it make the collider large?
i have not given RigidBody2d property to floor and ceilling, becuse whenever i make them RigidBody2D they drop downward. Can it be the reason what is causing problems
Did you read what I said about changing the collision mode? Try that.
On the 'ball' object, go to the Rigidbody2D component in the inspector and change the 'Collision Detection' property from 'Discrete' to 'Continuous'.
yes i had already tested it with Continuous value but it wasn't working.