Character Movement and Gunplay


Hello everyone!

This is is my first time writing a devlog so any feedback will be highly appreciated.

I started working on this prototype about 3 weeks back wanting to make a TPS game to learn more mechanics and gunplay. My initial inspiration for the game was Rouge Company which is a popular Third Person Shooter game that was released recently. 


Character Movement:

Since the character has multiple states like Wan, Run, Crouch, Dive, and Climbing and various relationships between the states, the first thing that came to my mind was to use a Finite State Machine to switch between the states and keep the reset to the correct one after that particular movement state was complete. Initially, this seemed to work well but then I ran into the issue of having the state reset to a previous state after the current one was complete. Like if the character was crouching before they dived the character should remain in the crouched state after they finished diving. So keeping these kinds of relationships became pretty hard due to the related links. 


The solution that I came up with was to have a stack that stored the movement. 

This ensured that I could push the movement onto the stack and when the movement ended, I could pop it from the stack. Then I could just evaluate the top of the stack to apply the related changes to the character. So the initial problem that I faced became really simple to solve with this stack back state machine. So when the player pressed Dive, a new state called Dive was pushed on the stack, the character changes re-evaluated. When the Dive was completed, it popped Dive from the stack and the changes was calculated again. So does not matter what the previous state was, after diving the character would return to its previous state.

More details can be found here


Gunplay and Recoil:

The Gunplay and Recoil system was something inspired by Valorant. This is because the recoil pattern of the guns in Valorant is not fixed and completely based on curves and random ranges. The way the gunplay works my this game in its simplest form is:

  • A constant is calculated based on a default error circle. This is applied to every bullet that is fired
  • At this point 2 constants are created, first a Zero::Vector and another based off the default error
  • The default error one is used to calculate the raycast offset from the crosshair position and the Zero::Vector is used to calculate the movement of the camera for recoil
  • After this a fixed Vertical Offset is added to both of these values 
  • After the gun hits the HorizontalRecoilStartBullet, both of these values are further multiplied by a sine curve to give them a horizontal motion
  • Finally the 2 values are then multiplied by 2 curves enable easy tweaking of the recoil and shooting
  • Extact detail of how it is working can be found here

Any feedback will be highly appreciated! The following week changes should include better netcode to handle latency, respawns and better gunplay!

Files

WindowsNoEditor.zip 352 MB
Mar 29, 2021

Get Third Person Shooter

Leave a comment

Log in with itch.io to leave a comment.