Overhauling the Shoot Mechanics


Author: Tyler Clardy
Date Posted: 6/11/2024

This Sprint I am focusing heavily on overhauling the Shoot mechanics. I am aiming to create a more robust and accurate Shoot ability for the player, since it is a core part of our gameplay. The previous Shoot worked alright but was very much a placeholder for use in our early versions.

To start with I create a line trace from the player camera to the center of the screen (where the crosshair sits). I then determine if a hit was detected or not, and set a Target variable based on this, using either the hit location (if a hit was detected) or the end of the line trace (if a hit was not detected)


Next, using the Target variable as an end point and the socket representing our gun barrel as the start, I line trace again. This is mostly for debug purposes - as the results of this line trace are not used, but can be very handy for developer work when visualization is enabled. I use the socket location and the target location to generate "Look At" rotation data and pass it into the creation of a transform, which then gets passed into spawning the bullet.


Lastly, I spawn in some VFX. A tracer for the bullet, to better see its trajectory, and a particle hit effect where it terminates at.


All of it can be seen working together here:

The line tracing in the above video follows this color scheme:
Green line - Camera to Crosshair
Red line - Gun Barrel to Crosshair
Purple - Hit Markers

My next steps for this overhaul include some bugfixing, primarily with the new mechanics being slightly unreliable at mid to long range (as can be seen in the video when I am shooting at the second enemy), and some animation work. Currently, our animations are not split for movement, meaning that when the player moves around his upper body moves a lot too. This swings the barrel of the gun around wildly and leads to some less-than-accurate shooting while moving. I plan to split our animations for the movement stuff so as to keep the upper body (and gun) steady during movement, with the notable exception of sprinting - as shooting is locked during sprinting anyways. I also intend to set up logic for the crosshair using a similar system to the line tracing seen above. I'd like to have the crosshair turn red when over a valid enemy target, and revert to blue otherwise.

Get Dimension Defender

Leave a comment

Log in with itch.io to leave a comment.