This week I went about trying to improve the opponent AI's perception of the game state (i.e which team is in possession of the ball, if any) in order to make them behave more accurately. I also added a player switching mechanic in order to easily swap players off the ball and eliminate situations where an AI player on the user's team is in possession of the ball. In addition to these features, I expanded upon the interceptions mechanic in order to make defensive actions such as tackling and interceptions, look more realistic by using path prediction. The remainder of the week involved minor bug fixes and overall polishing of mechanics.
How I went about making both the AI coordinators be more aware of which team is in possession is through triggering an event to which both coordinators are subscribed and dispatching this event every time the ball's handler changes, regardless of whether the switch is between two players of the same team, or even if it switches to none. I did this by leveraging Unreal's event system and having it owned and dispatched by the ball when the handler changes and it's subscribed to by the AI coordinators which use delegates to determine which possession state to transition to (offensive, defensive, loose ball).
Offensive:- Players try opening moving into open spaces to make themselves easier to pass to/ moving into better passing lanes.
Defensive:- Players are assigned to the player closest to their respective anchor positions (which is basically their designated position which changes dynamically based one whether their playing on the left, right or center) and position themselves close to their assigned players so that they are close enough to tackle or intercept the ball if it's played to their position. This assignment of players changes when possession transitions to the loose ball state.
Loose Ball:- The closest player to the ball's predicted position based on it's velocity is assigned to move to and intercept the ball. The remaining players move back to their anchor positions in order to maintain formation.
Event being dispatched when ball changes handlers. (There's a negligible delay in order to allow the path prediction calculation for interceptions to get the appropriate information required).
Adding a lambda that runs loose ball logic when ball has no handler.
The loose ball logic essentially involves moving the player closest to the predicted position of the ball in 30 frames to that position and having the remaining players move to their anchor position and waiting until the possession state changes to either offensive or defensive. This is the basis of the interception mechanic. The equation I used for predicting the path of the ball is ut + 1/2 at^2.
Loose ball logic that runs path prediction on the ball to try and intercept it.
The remainder of the week was spent on making minor adjustments to the passing and dribbling systems look and feel better and preparing for my final project presentation in class. I also found some models for bleachers and added them into the level to make it look more like a stadium in order to be more presentable.
Final gameplay demo.
Overall, the presentation went great and I got great feedback from my peers and professor and I am pretty satisfied with this project as I would have never taken on a project like this a year ago as I would simply be too afraid. I believe my passion for EA's FIFA titles and general love for football (soccer) enabled me to think about the design of certain gameplay elements. I also believe I did the naIve implementation of many mechanics and could improve on many of them, but it was necessary considering the mismatch between the time-frame and scope of this project. I would like to thank you for taking the time to follow my journey on this project and I would appreciate any feedback related to any work from any of the previous weeks.
Commenti