For this version I have begun giving the other players some AI, however it’s very basic for now.
For the AI player, if he detects that the ball is available he will run towards it. Once he collects it he will make a pass to you. I have also added the player velocity to the calculation so the space pass works even if you are moving. Of course, if you change direction after your team mate has passed the ball it will miss it’s target. This was the same in the original Football Superstars game as you cannot predict what another player’s change of direction might be, obviously. If you are in possession he doesn’t know what to do so he just runs in circles!
I also updated the goalkeeper so that he can detect the ball coming. He will now make a dive to one side or the other based on where in his detection zone the ball is. It’s not very accurate and needs modifying, but it suffices for now. The diving animations are taken from Mixamo.
This means I can now play a one-two with my team mate to score a goal, with the goalkeeper making a diving attempt to save it. He can’t actually save it yet but it looks good! I used the Unity Physics Raycast functionality on the goalmouth so that a target now appears for your player when you are aiming towards the goal. This gives you a better idea of where your shot is going when shooting.
You can see it all in action in the latest video below.