Last updated: Dec 13, 2022

Introduction

The Reload Behaviour State Machine Behaviour handles updating the magazine and the reserve magazine’s visibility based on the point of the reload animation we’re currently at. This is super important so that player’s can’t see weird floating magazines at random times!

You can find the Reload Behaviour at this path: Assets\Infima Games\Low Poly Animated - Modern Guns\Demo\Code\Animation\ReloadBehaviour.cs

Fields Serialized

Reload Type. The type of reload we're apply this behaviour to. We have two types, the Reload type, and the Reload Empty type.

Fields

Time Links. List containing all TimeLink values used to show/hide magazines.

Magazine. Reference to the equipped weapon’s magazine object.

Magazine Reserve. Reference to the equipped weapon’s reserve magazine object.

Methods

Updates the visibility of a specific magazine object if it needs to based on the current play state of the animation.

private void UpdateMagazine(GameObject magazineObject, string typeSearch, bool hide, AnimatorStateInfo stateInfo)

Makes a specific magazine object visible and takes care of raising certain events if needed.

private static void Show(GameObject magazineObject)

Makes a specific magazine object invisible and takes care of raising certain events if needed.

private static void Hide(GameObject magazineObject)

Determines, and updates, the visibility of a magazine object at the end of this animation state.

private static void DetermineEndVisibility(GameObject magazineObject, bool defaultVisibility = true)