
Prize Fighter - GroundedPunch
This is a script that allows the use of HexDog’s Grounded Punch attack, which is attached to the HexDog prefab. The script gets reference to a private instance of the PlayerBehavior script called pB, a private serialized GameObject called groundAttackHitbox, a private serialized GameObject called playerModel, a private serialized AudioClip called hexdogPunch, and a private bool called attacking.
In void Start(), pB is set to the PlayerBehavior script on the HexDog prefab, and the hitbox attached to the groundAttackHitbox GameObject is set false. This makes it so that the necessary references to the animator are found and the punch’s hitbox is turned off until the Attack function is called.
In void Attack, reference to the CallbackContext from UnityEngine’s new Input System is an accepted parameter. This means that when the proper attack button is pressed on keyboard or controller, the Attack function is called. Within the function, pB is checked to find if the player is considered grounded. If this is true, the attack hitbox is not active, and the attack function has been called, the attack hitbox is set to active, the player is attacking, and the player’s animator has its boolean to play the punch animation set to true. It then calls the coroutine AttackReset, which turns off groundAttackHitbox, sets attacking to false and sets the animator’s punch boolean to false after 0.5 seconds. As this coroutine is called, the Attack function randomly selects an attacking sound to play from HexDog’s possible punch sounds.
(1/3)

Prize Fighter - DivePunch, Part 1
This is a script that allows the use of HexDog’s Dive Punch attack, which is attached to the HexDog prefab. Similar to its grounded counterpart, this class gets an instance of the PlayerBehavior script called pB, a private Rigidbody called rB, and reference to a custom class called GravityScalePhysX, privately referenced as gSPX by DivePunch. This script was made to individually adjust the values of 3D rigidbodies, as Unity’s PhysX rigidbodies do not come with customizable gravity components. From there, float variables called gravConstant and dropDownMult are able to adjust the effects of gravity on HexDog before, during and after a Dive Punch is performed. Other key references include the GameObject divePunchHitbox where the attack’s hitbox is stored, a bool called divePunchCall that detects when the Dive Punch function is called.
In void Start(), the necessary references all get their respective components from the HexDog prefab. gSPX’s public float gravityScale, which adjusts the effects of gravity on a rigidbody, is set to the gravConstant value. From our testing, a gravConstant of 5f made HexDog feel weighty and satisfying to control. The divePunchHitbox’s activeness is set to false at the start, only activating when the attack portion of the Dive Punch begins.
The DivePunch class checks for collision with any surface underneath it. If the y position of the collision’s normal is greater than or equal to 0.5f, the Dive Punch in progress is ended.
In void DivePunchCalled, reference to the CallbackContext from UnityEngine’s new Input System is an accepted parameter. As discussed in the GroundedPunch class, this checks for the punch input’s calling. If a Dive Punch is not already active, pB returns false on the IsGrounded() bool and the attack input was performed, isDivePunchActive is set to true. As this occurs, HexDog pauses in midair to wind up his Dive Punch. After the pause is finished, the coroutine DivePunchDrop() begins, and the player loses the ability to double jump. This ensures the player cannot jump while descending with accelerated gravity and interfere with the intended falling behaviors.
(2/3)

Prize Fighter - DivePunch, Part 2
In void MidairPause(), the function DivePunchMovementChange(), which divides the defaultMovementSpeed float of pB by the dropGravMult float declared earlier. This constrains the movement of the player, giving them more minute control over where their punch will land. As this occurs, the player’s gravity scale is set to 0f, stalling the player in midair, and divePunchCall is set to true. This tells the animator of pB that the player has entered the windup state for a Dive Punch, and the corresponding sound plays to signify this change in state.
In IEnumerator DivePunchDrop(), the function readjusts values of the player after a number of seconds equal to the divePunchAirPause float passes. Earlier in the DivePunch class, the default value is declared as 0.5f, so the changes of the coroutine will apply after half a second elapses. The gravityScale float of gSPX is set to the found product of gravConstant and dropGravMult. These default values are set to 5f and 3f, respectively, meaning the player’s gravity is amplified by a factor of 15f. The divePunchCall bool is then set to false, and the animator boolean isDiveHolding updates to reflect the change in state. At the same time, the isDiving animator boolean updates with a value of true, putting HexDog into his Dive Punch animation as a sound effect plays to affirm this change further.
In void DivePunchEnd(), the player’s movementSpeed is set back to its default value, giving full control back to the player. The gravityScale float of gSPX is set to the gravConstant, meaning the force of gravity is influenced by the default factor of 5f. From there, the bool isDivePunchActive sets to false, which is then passed into the animator’s isDiveHolding and isDiving boolean checks. These two values being set to false update the animations of HexDog to stop playing the dive-related animations. As the player lands, the divePunchHitbox GameObject containing the collider for the Dive Punch attack is set to false. With all the checks being reset, HexDog is able to perform a new Dive Punch attack once he’s in midair again.
(3/3)