This site uses strictly necessary cookies. More Information

X- Home /

# [Physics] How to Make Balls hit at the same time but bounce different heights

I am making a pong-like game and ran into a physics/math related problem.

I have a ball that bounces off a paddle and needs to hit it again in a certain number of seconds (which I already have). I would like to have a control that makes it bounce a certain number of world units high (1-5 for instance). I tried doing this by adjusting each ball's gravity, which for the purpose of my game is totally fine, as physics are all calculated by hand.

I used the kinematics formula dY = v0t + 1/2at^2 as a starting point. Solving for a, I got

a = [2(dY - v0t)] / t^2

I used this equation to solve for gravity. When I set the balls' gravity to this value, it does accelerate faster or slower, but they don't all hit at the same time (which is my goal). Am I going about this all wrong, or just applying this formula incorrectly?

**Summary of Variables**

**time (t):** known

**deltaY (dY):** known

**initial velocity (V0):** negative impact velocity?

**gravity (a):** calculate

**Ball Code**

```
// How much time in seconds until next hit
float moveTime = CalcBounceTime();
// Get the distance to move
float radius = GetComponent<SpriteRenderer>().bounds.size.y / 2;
float deltaY = bounceHeight - radius;
// Get Time to reach peak
float halfTime = moveTime / 2;
// Get the initial velocity
velocity (from variable);
// Calculate the gravity
gravity = (2 * (deltaY - velocity * halfTime)) / Mathf.Pow(halfTime, 2);
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Need a math geeks help. point at which a line hit a plane 1 Answer

Calculate Height of Trajectory : Unity3d 1 Answer

How to calculate desire angular velocity? 1 Answer

How can I create a random integer value that is a common multiple of two other variables? 2 Answers

ForceMode.Acceleration estimated dst != covered dst with a single Addforce in effect 1 Answer