- Home /
problems with the collision speed
I created a ball bouncing between two walls, and each time it bounces gaining speed, but after a while pierces the wall. I think because the ball goes too fast and the unity is not able to calculate the collision. (though for what I want, the ball still goes floor) there is a way to overcome this problem?
$$anonymous$$ake the walls (colliders) thicker. Perform physics in FixedUpdate only.
Answer by Dave-Carlile · Nov 09, 2013 at 06:40 PM
If you're using Unity's physics you should be able to set a drag value on the rigidbody which will effectively cap the maximum speed. You'll need to play around with the value until you get the effect you want.
If you're moving things manually, you just need to cap the maximum velocity. There are multiple ways to do that but it's hard to tell what's best without seeing your code. One method is to use Vector3.ClampMagnitude on your velocity vector. This will clamp the vector length to a maximum value, which means velocity won't go beyond that value.
unfortunately I'm new to unity and I do not know everything well. what I did is this: 
there is this paddle that move me, and the ball goes faster and faster and I moving the paddle I try not to let the ball fall. the ball does not have a script for the speed, I just set the physic material rebound.

what do you suggest I do?
The "Your Answer" section is reserved for answers to questions. Discussion should be done using the "Add Comment" button under the answer you're discussing. I moved your comment here...
Does your ball object have a rigidbody component? Set the drag property on that to a value higher than 0.
is my ball has a drag property, but if it imposed greater than 0 the ball goes very slowly, ins$$anonymous$$d I want him to go faster and faster.
Your answer