- Home /
OnCollisionEnter not being called while changing (unity Physics System) Gravity Value
Hello everyone, I added upward force on ball with the help of OnCollisionEnter detection on gravity value -9.8. However, when I change it in unity physics system to -9.0 or some other value. It is not being called to force the ball go up and come back. It is just like bounce ball for effective purpose. I have shown in two images where it hits and generate particle effect but in another image which represents that it gets stuck in mesh.
Problem is in this image. Why OnCollisionEnter Function is not being called?
Answer by Insok · Jul 26, 2020 at 08:24 PM
Just to make sure: Your ball object needs to have a Rigidbody component and both objects need to have a collider component. Both colliders set to isTrigger = false. The Rigidbody component must not be kinematic.
If this doesn't work, I see that you are using Unity 2017, make sure that the Rigidbody component is above the collider component in the ball object.
If that doesnt work, try scaling up your colliders and see if it works then. Your objects might be too small causing the colliders to not register it.
Answer by arslanaliawan34 · Jul 27, 2020 at 05:41 AM
I solved my Issue because it was issue inside the check of OnCollisionEnter otherwise everything was fine. Most of the time, when we use if-else checks in these types of methods, they can be hit for logical error problems on triggering and adding forces etc. Thanks for community to answer about it for further guidance to me.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Virtual reality basketball, issues with pointer and transfrom down 0 Answers
How to make a system that will let elements interact with other elements? 1 Answer
Multiple Cars not working 1 Answer
WheelCollider is weirdly affected by Solver iteration count 0 Answers