Overview
Item View is the component that plays an equipped item’s animations and sounds. In Sci-Fi FPS Pack, weapon views inherit fromGameplayItemView so they can animate the weapon and the character together.
For example, when you reload, the character animation moves the hands while the item animation moves the magazine and bolt. The view starts both from the same call.
The example gameplay component decides when an action is allowed. The view plays the corresponding animation and effects. This lets you keep the weapon animation setup when you replace the example controller with your own gameplay code.
Component setup
Place the view on the item prefab’s root alongside itsAnimator. The character example creates the item under the character’s mapped weapon bone.
- Procedural Asset defines the character’s idle pose and procedural features for this item. Equipping the item passes it to the character’s animation controller.
- Item Idle Clip is the item’s own resting animation. A looping clip plays continuously; a non-looping clip is held as a static pose.
GameplayAnimationController animates the character hierarchy. Keep character and weapon clips assigned to the corresponding side of each action.
Paired animations
GameplayCharacterItemClip stores these three references:
PlayCharacterItemAnimation(clip) plays the character asset through the character controller, plays the item asset on the item Animator, and plays the sound through the player’s Audio Source. Pass true as the second argument when the caller handles sound separately.
clip.GetLength() returns the longer duration of the character and item assets. Draw, holster, reload, and inspect methods use this duration so gameplay can wait until the action finishes.
You can also play an item-only action:
false when the item graph is not initialized or the asset has no clip.
Equip and unequip
OnEquipItem(player) finds the character animation controller, camera, and Audio Source. It then applies the item’s procedural asset and the item scale stored in the character’s retargeting override.
Always run equip initialization before using a view. Pass the player GameObject explicitly when the item belongs to a character under another parent object.
The base GameplayItemView does not contain draw or holster clips. WeaponView and ThrowableItemView add those actions. Weapon equip also takes the fire rate and fire mode needed to initialize recoil; see Weapons.
Item actions
These methods are virtual. The base class leaves use, stop-use, aim, and inspect behavior empty for derived views to implement.
How the example calls the view
GameplayItemExample caches the view in Awake. Its EquipItem, UnEquipItem, UseItem, StopUsingItem, Aim, and InspectItem methods forward calls to that view.
The character controller calls the example component after reading input. For firearms, WeaponExample adds ammo and firing timers before calling the weapon view. Character explains that sequence.
Visibility and sound
SetItemVisibility(bool isVisible, float delay = -1f) activates or deactivates the item GameObject, immediately or after a positive delay. Draw and holster implementations use it to reveal the item after drawing starts and hide it when holstering ends.
HideBoneByName(string boneName) forces a bone to a very small scale in LateUpdate. Use it for parts that must disappear during an animation, such as a magazine. UnhideBoneByName removes that forced hiding; the animation must write the visible scale again.
PlaySound(AudioClip clip, float pitch = 1f, float volume = 1f) plays a one-shot sound through the Audio Source found during equip. Use animation events when a sound needs to happen partway through an action.
Use Item View with your controller
Keep the view and animation references on your item prefab. Your controller should initialize the view when equipping, call its action methods when input or gameplay changes, and wait for returned durations where actions must not overlap. If you replaceWeaponExample, also implement ammo access and firing timing. Calling WeaponView.OnUseItem plays a shot’s effects; it does not create a projectile or apply damage.
For the six item prefabs and their specific components, see Weapons.