Bro Code logoBRO CODE CRINDEPENDENT GAME DEV TOOLS
← All abilities
ABILITY 02

Shield

Block damage and knockback while active, with configurable resistance and a shield visual.

Activation

ShieldButton

Example use

Explore the setup guide below to configure this ability.

Ability documentation
CHARACTER ABILITY
SETUP GUIDE

Set up this ability

Component
CharacterShield
Source
Scripts/Abilities/CharacterShield.cs
Animator bools
Shield

Component dependencies

Requirements for this ability and its targets
ComponentWhere to add or assign itPurpose / setup
HealthCharacter GameObjectRequired for damage and knockback protection.

Visual component dependencies

These components support the associated effect. A missing optional visual does not by itself imply that the gameplay mechanic cannot run.

Visual dependencies
ComponentWhere to add or assign itPurpose / setup
ShieldVisual + SpriteRendererShieldPrefab rootRequired for the supplied shield visual. Assign BasicShield; create an Overlay Sorting Layer and arrange it above the character. Script: Assets/CorgiAddOns/Scripts/Abilities/ShieldVisual.cs.
  1. Add CharacterShield to a CharacterPlus character with Health.
  2. Assign BasicShield to ShieldPrefab. Its root needs ShieldVisual and its hierarchy needs a SpriteRenderer.
  3. Create a Sorting Layer named Overlay and arrange it to render above the character.
  4. Set HitsResistance to 0 for no hit-count limit, or a positive count to request a break after that many OnHitZero events. Use ActiveTime for a duration.
  5. Activate with ShieldButton. DamageDisabled and ImmuneToKnockback are enabled while active, then reverted on stop.

Inspector reference

These are C# field declaration defaults. Existing prefab and scene values can override them. Shared fields are documented under Ability Configuration.

CharacterShield fields
FieldTypeDeclared default
HitsResistanceint0
ShieldPrefabGameObjectNot assigned in declaration
ShieldOffsetVector3Vector3.zero
AutoScaleWithCharacterbooltrue
ShieldColorColornew Color(0.4f, 0.8f, 1f, 0.4f)
PulseEnabledbooltrue
PulseSpeedfloat2f
PulseMinAlphafloat0.2f
PulseMaxAlphafloat0.6f
HitFlashEnabledbooltrue
HitFlashColorColorColor.white
HitFlashDurationfloat0.12f

Usage notes

  • Use the included BasicShield prefab as the starting point for your shield visual.
  • When both inherited movement and condition blocking arrays are empty, initialization sets Jumping, WallClinging, Falling and WallJumping as blocked movement states.
  • Hit resistance uses Health.OnHitZero events to count absorbed hits.