470 Sprint 1
Work Completed
For this sprint, I worked on the enemy AI. I had to do some research on how other games went about programming their AI. One instance was the game Rocket League. This game has a similar basketball mechanic so this is where I started.
One programming technique I used was a state machine. This let me program different states I wanted the AI to be in. In this first sprint, I created the base classes for the idle, chase, and attack states. These states can be cycled through depending on the range of the AI and other game objects. Each state inherits the base OpponentState class that is simply a template for what functions need to be run. For example, each state has a FrameUpdate state which handles what happens in that state each second it is in that state. Then some other ones like EnterState and ExitState. These can tell the AI what state to go to next depending on the game scene (get out of range for the attack state: switch to the chase state).
If the AI is within 10 units of the ball, it will go into the "chase state" where it will execute the code related to that respective state. For now, it gets the position of the ball and goes straight towards it.
The other state the AI can be in is the "attack state" where the AI will execute its attack code. If the player is within 5 units of the AI, the AI will go straight towards the player. There are no attacking methods yet, just simple movement.
As you can see in Unity's scene mode, the colliders are highlighted to show the range of each state. This works for now, but there may be a different way to implement the same outcome to save performance.
Another aspect I worked on was ball physics. We want the ball to bounce and be lightweight so that it can bounce off walls and get some air time when hit by a force. To do this, I utilized the physics material that is provided by Unity as a component to add to game objects. For now, the ball bounces and moves when touched by the AI. Future implementation will be made so that the ball can be hit up and towards the goal.
What wasn't completed was the attacking of the player. This will be worked on next sprint once the states are cleaned up. A buffer between attacks will need to be utilized so that the enemy doesn't spam attack the player.
Another thing that needs to be handled next sprint is the force being added to the ball by the AI or the player. This is needed so that the ball can get into the hoop and the ball isn't just dragged along the ground when hit. Another thing that will need to be looked into is how to get the AI to hit the ball to a certain hoop and add variation to their hits so that the ball isn't hit exactly the same each time.
How this Process Has Been Different
This process has been different because I haven't created a state machine for a game project before. It took a good amount of research to decide what programming pattern would work best for our game's AI. I think the state machine can be useful since the AI will be doing many different actions. Going forward, I will look into how to implement physics into the game that is responsive and realistic. Since this is sprint 1, some programming techniques may change once I spend more time researching efficient and clean coding practices.
Comments
Post a Comment