top of page

370 Blog Post 2

Following a successful paper prototype of our game at the end our first Sprint, we decided that it would be a good idea to cut down the scope of the game and focus on the most fun part of the prototype: the shotgun propulsion jumps. As the programmer of the team, this meant putting extra time and effort to ensure the character controller and shooting felt as smooth and comfortable as possible. After quickly setting up the project with Unity Collab, I began creating a player with a Character Controller component to allow for more precise controls than using a character with a rigidbody and the Unity physics system.

Platforming.gif

To properly test the movement and jumping abilities of this character controller, I created a basic scene layout with Probuilder, containing a series of platforms which increase in height and distance. The move speed, jump height, and gravity of the Player Controller script are publicly modifiable so that it is easy to quickly make adjustments and see what feels best.

Player_Controller.PNG.png

Once I got the movement and jumping to my liking, I began working on being able to aim and shoot a gun. The way it works is by using a large empty trigger box set to its own layer which can't interact with other things in the game, and performing a raycast from the camera to the mouse pointer. The raycast is masked to only detect the invisible trigger box, and thus we can translate the mouse position into a game worldspace position with which to point and shoot the gun. The math to get the gun to rotate towards that position is a bit tricky, but here is what I've got at the moment.

Aiming.gif

After getting the gun to point towards the mouse cursor, I needed to add a 'fire point' to the gun and instantiate a bullet that moves from the gun's fire point in the direction of the mouse cursor. I also looked up a method of adding force to a character controller component based character (as I cannot use the 'AddForce' method of a rigidbody) so that I could apply knockback to the gun's shots in the opposite direction of firing.

Shooting.gif

Finally, I needed to prevent the player from shooting as fast as they could click and flying into the sky. To accomplish this I added some variables to control a lot of different attack stats, such as the damage, bullet speed, number of shots per reload, the reload time, the knockback force, and a checkbox that allows us to decide whether to only allow the player to reload while on the ground. 

​

This setup allows for a lot of control over the player and allows us to make adjustments to it on the fly based on the feel of it while playtesting.

​

Overall I'm really happy with the progress I've made thus far and am looking forward to adding more functionality before the first build of the game.

​

Till next time!

Player_Controller.PNG.png
bottom of page