Joining Monochromatic, the first task I had was to become familiar with the engine that we were using. The most difficult part of this was to become used to the way we had to create stuff in the game. Our engine, “ghoti”, uses an entity-component system instead of OOP like I’ve always known. Because of this, I made sure to take my time combing through as much of the engine as I could to get a better grasp on it.
Once getting more familiar with the engine, my next task was to begin reworking the player that Logan had left behind. The first step for that was the movement of the player. The initial thing I needed to change regarding the movement was how the player changed directions. The player would snap to 45 degree angles, which would not be ideal for anyone playing our game with a controller. Once I had the player no longer snapping to angles, I discovered a bug with the quaternion slerp function in our math library, kazmath. Essentially, the way quaternions rotate with kazmath is to use a positive and negative axis for x, y, and z. Each positive and negative axis would go from 0 to 180 degrees, creating the full 360 together. The issue that this has is when a quaternion “crosses” an axis, changing from positive to negative or vice versa. When this occurs, the angle of rotation converts to an angle above 180, instead of being a negative angle. Because of this, the player would immediately do a 360 in the opposite way it was going, which didn’t look right at all.
To solve this problem, I had to create an algorithm that would check the angles each time the model tried to rotate, comparing the current angle to the desired angle and the associated axis of each angle. If the desired direction was on a new axis, I replaced the current rotation with that of one on the desired axis with a negative angle. This fixed the unnecessary 360 the player would do when crossing the axis, since it never does when actually calling the slerp function.
That wraps up my first week on the project. During the second week, my tasks were to rework the combo system that Logan had started, and to work on the camera’s ability to follow the player and orient itself in the way they were moving. The combo system was not much of an issue, and I had that completed and working fairly quickly. The real problem of the week was the camera.
The camera was something I definitely underestimated, looking back on it now. Things had started off well, with me modifying the camera we already had to start following the player. Pretty quickly I had it lerping behind the player and rotating to face the same direction they were. The issue with what I had was when the player would do sharp turns, particularly when they would do a 180 without moving much. Doing a 180 without moving caused the camera to fly straight through the head of the player, cutting into the model and showing the inside of it.
I tried various methods that I could think of to fix this issue, and eventually found one that limited the yaw and pitch on the camera so that the clipping was mostly avoided, but this didn’t change the fact of how the camera moved. The camera still moved in a straight line behind the player, when our ideal movement would be for it to move around the player in a circle.