470 Sprint 4

Work Completed

For this sprint, I worked on adding a pause and main menu system, adding teammate rat AI, and fixing the implementation of the opponent rat AI, specifically the AI force upon the ball once contact was made.

The pause menu is simple at the moment. It has two different buttons which are resume and quit. This uses the event system, so whenever these buttons are pressed, they execute the function linked to the inspector. For this I have made a function to pause the game and set the game speed at 0, this will make everything stop on screen. Pressing "RESUME" will have everything return to the normal speed rate of 1. Since we do not have a main menu UI system implemented, the quit button will send a message to the console letting us know that the function has been called upon. In the next sprint, it will be my job to make a main menu to link these two components together.

I also worked on teammate rat AI. Before, there were just opponent rats, but now with a few scripts I created teammates with similar functionality as the opponent rats, but instead attack opponents and try to score in the player's basket.



There will need to be some optimizations and reworking in the code going forward, but the teammate rat goes into different states based on where they are relative to the ball and opponents. The things that need to be improved on later are making it so that the teammate rat targets any opponent and not just one, and also being able to reposition into multiple spots depending on if another teammate rat is at that position already or not. These are things I will be working on in the upcoming sprints for the final build.


These are the classes I created to make the teammates change states. They are very similar to the opponent's state machine. While it does work, I will look into seeing if I could use the same script for the same states the two AIs share. This way I don't have to copy code and it can be cleaner and easier to read.

One of the issues I was able to solve this sprint was the force AI gave the ball upon contact. Before, I thought it was a scaling issue because the ball wouldn't have a force placed on it if it was larger than the AI rat model. After discussing this issue with the team, and with the help of Christian, we were able to figure out that the raycast couldn't reach the center of the ball's model. After making the distance needed to add force a lower value, the AI was able to add forces to the ball like normal again. One thing that I may need to look into is using OnCollisionEnter instead of Physics.Raycast so that the size of the ball doesn't matter for the AI to add force to it.



Comments

Popular Posts