Close

July 23, 2018

Fighting Game Day 4

Apologies again for the brief hiatus, I’ve had some other pressing concerns, with Senior year on the horizon, much more of my time is going to studying for standardized tests as well as to prepare for college applications. But today, I’ve actually got some spare time. So, I decided to revisit my fighting game. Specifically, I wanted to fix some of the internal issues I ran into upon earlier testing such as the camera freezing or not showing both players, or the ai not fully utilizing a combo. This meant going through the code multiple times in order to discover the sources of the issues. For the camera, it turns out that the code was working perfectly fine, however, I didn’t set the transform of the camera to the origin (0,0,0) which was causing the issues mentioned above. As for the AI, the issue was additionally quite simple, to randomize the AI’s progression through the combo, I created a random variable between 1 and the number of attacks in the combo, however the function Random.Range() utilizes a min and a max, both of these parameters can be an integer or a float, as long as both the max and min are the same type. However, if the values are integers, the maximum is exclusive, this turned out to be my issue, as I was using attackPatterns.length – 1, (this was to generate a random number to select the combo) as I was under the impression it was inclusive —which would be the case if these values were floats— so, by simply removing the -1, the AI would now sometimes finish their combos.

As that issue was fixed, I decided to make the project even more easy to elaborate on. To do this, rather than adding in characters manually then adding them into the character select screen manually as well as organizing the portraits, I had the code do this. The class was quite simple, it would merely loop through all the characters made by the user and create a portrait for them. Although, due to this I had to give the character class more parameters that need to be filled out upon creation of characters, parameters such as an icon, background color, etc. Then by using a built-in component in Unity called a grid layout, unity itself would organize all of the portraits, allowing me to spend time later on for other more pressing concerns.

Another thing I wanted to do was make the AI more variable. The current way the AI decides its actions is with a series of variables for its attack rate, move rate, close combat rate (how quickly the AI resets back to the default state), etc. But to make the AI more variable I decided to simply make the actual rates for all these variables to be a random value between a minimum and a maximum. This is pretty self-explanatory, each AI has a min and a max for each rate, and the program calculates a random actual value.

 

Leave a Reply