- Home /
Unity 2D - How do I add the velocity and direction of an object to another object?
So I'm trying to make this pong game that allows the player to move the paddles forward and back. This often causes issues with the ball bounce- sometimes it will just roll on the paddle and lose all its velocity. How do I add the paddles velocity and direction to the ball when it bounces/collides with it?
Answer by logicandchaos · Oct 03, 2021 at 02:38 PM
Velocity contains direction. All you have to do it set the velocity of one object to another.
ball.rb.velocity=paddle.rb.velocity;
where rb is a rigidbody component.
Answer by TalkingBlah · Oct 03, 2021 at 04:20 PM
hi did you tried physics material (bounce on the game objects instead of velocity) to make your ball bounce up?
if you still not fixed it comment me back and i'll try to help you with the issue.