- Home /
Object is sliding off instead of bouncing!
Hi guys i need some help in setting up this physic properties in unity. I am trying to make a air hockey game and i opted to use physics properties on walls and a puck. But i dunno why some times the puck slides off the walls even the the property is set to 1 (i mean the bounce)and when it has more velocity then only it is bouncing off those walls.
As you can see that white puck is stuck to those walls(invisible colliders).And one more thing is how do we actually move the player with mouse when the camera is angled? the one i did with ray casting is actually not looking really impressive Please any help would be really helpful thank you.
Answer by philjhale · Apr 17, 2014 at 08:21 PM
I had a very similar problem and fixed it by reducing the bounce threshold.
Edit -> Project Settings -> Physics
This helped me tremendously. It exactly fixed my problem in a pong-like game
Answer by Lordinarius · Mar 05, 2014 at 01:04 PM
Instead of using physics properties, I think you should make your own calculation.
You have 4 walls (Right, Left , Up, Down)
If your puck collides with right or left walls you can simply inverse X axis of puck's velocity. And if the puck collides with up or down walls Y axis should be inverted.
Example Code
Vector3 myVelocity = puck.rigidbody.velocity;
myVelocity = new Vector3(-myVelocity.x,myVelocity.y,myVelocity.z);
puck.rigidbody.velocity = myVelocity;
Answer by rakesh_dev · Mar 07, 2014 at 05:16 AM
Hi lordinarius the issue is with colliders and it is happening because of the puck is hitting the walls and its getting stuck there instead of bouncing.
Unity physic egine sometimes is not working properly. If your object's speed is too high, sometimes objets passes through colliders. In order to overcome this issue, you should make your calculations with using raycasting
Your answer
Follow this Question
Related Questions
Unity 5: Mecanim/Animator-Driven Collision No Loner Sliding Along Walls 1 Answer
When I use Physics2D collider, Bounciness of 1 is slightly wrong. 0 Answers
3D enemies keep sliding on the terrain 1 Answer
PhysicMaterial Property Change Not Effective If Change During Collision 0 Answers
2D Slope Sliding: how to prevent with transform.translate logic 0 Answers