How do I implement the first touch system just like in Fifa or Pes

Started by
0 comments, last by NDraskovic 8 years, 5 months ago
i have been working on a soccer game for the past several months. I have managed to set up a decent A. I. I am now tweaking the A. I so that it looks better and realistic. One of the area I would want to tweak is what happens when the player receives the ball. Currently the ball stops dead at the player's feet. I would want it to be like the player takes note of how much speed the ball is travelling with and the player decides on how much force he should use so that the ball stops in front of him. I know depending on the player's ball control states I can use it to decide a certain range of power the player can use (players with less accuracy have a greater range increasing there chances of making errors). I haven't tried it yet so any ideas on how to do this will be greatly appreciated.
Advertisement

Without any code it is hard to guess, but I would use this approach:

Perfect trap:
- Extend the collider that you use to detect that the player is receiving the ball (just slightly, so that you have a few pixels of space between players legs and the edge of the collider).

- When the ball collides with the collider, use Vector3.Lerp function to "smooth" the transition between the points in which the ball is moving and when it stops.

- You can put that Lerp function in an if() block, and use conditions like player stats, speed of the ball etc. to determine if the first touch will succeed or if the ball will bounce away from the player.

Imperfect trap:

- If you want it a bit more realistic, you could use two Lerp functions - one to regulate the transition from the edge of the collider to players feet (time right before the trap), and the other from his feet outside (time after the player tries to trap the ball). Depending on players skills, the second Lerp can regulate the speed, distance and direction in which the ball would go after the player tries to stop it (naturally, if the players stats are higher, the ball will fly a smaller distance, and stop closer to the player than if the stats are higher)

This is just an idea, hope it helps.

This topic is closed to new replies.

Advertisement