Football kick .

Hello ,

I am starting a game like [Football Kick][1] . But , I can’t get the logic for ball curve . Is it using physics , or movement along bezier curve. Please show me the right path .

I would think the simple idea is to have a stating velocity and a curve velocity.

Both are defined by the shape of the touch (or other variables but this sounds logical to me for mobiles). So the initial velocity would be the magnitude of the slide that you clamp while the curve velocity is the shape of the slide.

Here is how I would try:

  • Get touch at frequency
  • Record touch in list
  • Draw vector between touch 0 and touch 1 → vec0
  • Draw vector between touch 0 and touch 1+n → vecn
  • Get angles between vec0 and each vecn
  • Get average of the angles
  • Get polarity (going left or right)
  • This average will define the x velocity of your ball

The y velocity could be defined with the difference in y position between the start touch and the highest touch and clamp that as well.

Now that you have the z velocity (initial), the y velocity (start and highest) and the x velocity (curve) you should be able to shoot. Each step is modified by the player factor, is he good or bad.

Those are just thoughts but I guess this could get you starting.

What you can do then is kick the ball with z (forward) and y (vertical) using add force, then apply a force with the x value. This will get the ball to curve its direction.

Now if you want to give it a more realistic shape, you would have to use the value of x to modify also the initial velocity. See when you kick the ball with effect, the ball seems to go out of direction and then back into it. So you could use half of x in the initial and then x to move the ball back in.