How to hit the ball?

Hi everyone.

UNITY 2D C#

I started a project in which I would like to create a ball that I can hit.

The problem is that I would like a field type to appear around the ball.

In this field I can choose where and how hard I hit the ball.

If I click further to the ball (in the field) this one should be hit harder.

If I click closer to the ball (in the field), it should be hit lighter.

The higher I press, the larger the angle of impact must be.

It’s hard to write what I mean because I do not come from an English-speaking country.

I showed everything in the attached movie.

I do not know how to do it because I’m doing it for the first time.

Maybe someone has already created something similar and can help?

link text

You probably could use physics for this. It would not be that difficult to calculate some kind of parabole, but I’m not confident in my parabole abilities so I will explain the physics part.

To use physics with your ball you need a Rigidbody2D. You will move your ball with Rigidbody2D.AddForce. Looking at your gif, you should probably use ForceMode2D.Impulse.

From now it’s easy. You just have to get the force Vector as MousePosition - BallPosition. And feed it to AddForce method.