I'm learning Unity by creating a simple 2D bat & ball prototype game. A ball (Rigidbody2D with sphere collider and a bouncy Physics 2D Materia) is dropped under gravity from a height, and bounces off a player-controlled bat, which is moved via the mouse. It works fine with Discrete Collision Detection set on the Rigidbody2D component, but can graphically over-shoot the bat sometimes. A Brackey's tutorial mentioned setting the Collision Detection to Continuous to get more accurate collisions, but when I do this on the ball, it will bounce the first time, but on the second collision with the bat, the y velocity gets set to zero (according to a Debug.Log call), and it therefore stops bouncing. I'm not touching the velocity in OnCollisionEnter2D, leaving everything to the built in physics engine. The Balls also has an empty Update() function, so nothing going on there.
What can be causing the y velocity to suddenly disappear when setting the RigidBody2D Collision Detection to Continuous, and what is the correct way to solve this?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
103 People are following this question.
Bounce not working when Velocity is below 1f , what could it be?
[Solved] Zero out Velocity before double jumping?
OnTriggerEnter2D at high velocity
Rigidbody2D is falling slowly when using velocity
Rigidbody rotate velocity