How to punch a ball without loosing its momentum?


I’m trying to code a Breakout/Arkanoid clone with Unitys built-in physics.
At the moment I’m working on the behavior of the paddle, when it gets hit by the ball. I would like to have it bounce towards the ball, so the ball bounces back again. So far I assigned the Bouncy material to the paddle and the walls. I also found a cool effect in iTween:

var bounce : int;

function FixedUpdate () {
if (Input.GetButtonDown("Fire1")) {
	iTween.PunchPosition(gameObject, iTween.Hash("z",bounce, "time",0.25));

The animation is cool, but the ball looses height and momentum and therefore stands still after a while. Is there a way to achieve this effect with maybe ‘AddForce’, so the ball won’t loose its “bouncing”-energy?

There are a few things that will be slowing your ball down. The first and most obvious one is gravity, which will add a constant downward force to the ball, causing it to slow down and eventually fall off the screen or settle. It’s easy to turn off…

The second is drag, which is a setting on the Rigidbody. Drag will slow down the motion of your ball, which will cause that loss of height and momentum over time. In a breakout type game the ball doesn’t normally have drag so this should be set to 0.

Simply moving the paddle forward while it’s set kinematic might not give you the kind of motion you want, since the momentum of the kinematic paddle isn’t going to carry into the collision like it would in real life. A good way to add some extra punch to a collision is get the velocity of the other object after the collision (in OnColliderExit), normalize it… and then multiply it by the magnitude of force you’d like to add… then add it as an impulse to the ball. This will give speed up the ball and give it a good amount of extra force without changing it’s direction.

yes you’re right - it’s more about tweaking the physics configurations here and there.

again thanks for your advice!

yes, you’re right. it’s more about tweaking the physics configurations her and there. I’m starting to get the hang of it.

again, thanks for your advice!