How to alter the bounce of a ball? Add force when hitting a ball?
Hello, I am pretty new to unity and programming but i am trying to make a super simple game in which a ball bounces on a ping pong paddle, but I want it where you have to move the paddle up when hitting the ball in order to keep it bouncing, (like real life). I currently have set up a scene where I have a paddle, and a ball, and both have a physics material with the bounciness at 1, and a script to count the score whenever the paddle and ball collide. I also have a script to move the paddle around when you drag it with the mouse, but it moves with transform.position and the movement of the paddle does not effect the upward velocity of the ball at all. I assume I probably need to move the paddle with physics too, in order for it to add their velocities but I don't know how to do that or if that is even a good or possible way to do it...
It sounds like you're on the right track. You're right in thinking that you need to use the physics system to move the paddle if you want it to apply a force to the ball. There are a number of ways to move a Rigidbody, so I would start by reading the API docs, specifically the public methods section, to decide which one works best for the control scheme you're going for.
Your answer
Follow this Question
Related Questions
Ball won't stop bouncing 1 Answer
Ball Physics? 0 Answers
Sphere is not using OnCollisionEnter/OnTriggerEnter/OnCollisionStay/OnTriggerStay functions 0 Answers
Unwanted behavior when manipulating a public integer from a different script: How can it be fixed? 1 Answer
character not moving, though code seems to be right 0 Answers