Hello,
i have just started using unity few days before and for some practice i started following the Beginners Break-Out game tutorial from this site, but the problem is after scripting on the ball, my ball is not bouncing back from the wall, i’m copying the exact tutorial and the code is same but it’s not working with me while it runs perfectly on the video " Mini-Projects from the Recorded Video Training Archive - Unity Learn "
Any help will be predicated, thanks !
As I understand your problem, the ball simply passes through the wall instead of bouncing off it, correct? Some things you might want to check for:
- In the colliders for your wall objects, is the “Is Trigger” box checked? Setting colliders to be triggers removes any collision.
- If two objects collide and the RigidBody components for both are set to “Is Kinematic,” they will simply pass through each other instead of bouncing. Setting objects to be kinematic removes them from most physics calculations, and it’s possible both your ball and wall are set to be kinematic.
- If you are calling the “OnCollisionEnter” function, make sure everything is capitalized correctly! I was recently very frustrated only to find out that I had mistakenly typed “onCollisionEnter.” Doh!
- Make sure your colliders and rigidbodies are enabled in the first place. If they’re disabled in the inspector, obviously they won’t be doing anything in your game.
- EDIT: Also make sure you’re using all 2D colliders and rigidbodies or all 3D colliders and rigidbodies. A 2D collider will not collide with a 3D collider and vice versa.
Hope this helps!