Author: Matthew Chadwick
Date: October 28th, 2023
While implementing an animation for throwing something in CyberSiege, I realized that I would have to prevent the player from shooting their weapon while the animation is being played. If the player was able to shoot while throwing a grenade, the animations would most likely override each other and result in the player never completing the throw animation, which in turn, would cause the player the become soft-locked and unable to throw more grenades. There were a handful of solutions to this issue, most of which would be considered "Bad Ideas". However, I was able to find an easy solution without minimal additions to the player and weapon holster classes.
Currently, the animations for the player are decided by an enum stored in the current weapon they are holding. For information on the animation switching, I explained it previously here. Since the throwable isn't actually a weapon, I wasn't able to simply switch to a different blend space for throwing a grenade, which wouldn't be practical in the first place. Instead, I created an "Unarmed" weapon that the weapon holster has a reference to. Using the new Unarmed weapon, I was was able to use the pre-existing functions to have the player holster their current weapon and switch to the unarmed weapon.
This did two things: it prevented the player from firing a weapon since the Unarmed weapon has no overridden Fire function, and it left the player's upper body free to throw a grenade. Next, the throw grenade animation played, which, after it ends, spawns the grenade from the players hand and equips the same weapon they had before throwing a grenade. The result was a smooth transition to the throw animation while preventing the player from firing or throwing anything else while the animation played.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.