Zum Hauptinhalt springen

Cross-Affect Setup

Cross-affects map a source state on one component to affect tags consumed by another component on the same Pawn.


Example: Starving Reduces Stamina Regeneration​

  1. Add and activate Food and Stamina components on the same authority Pawn.
  2. Enable bFoodComponentAffects and add a FoodAffectMap entry with key Cube_Survival.Food.Starving.
  3. Put Cube_Survival.CrossAffect.Stamina.ReducedRegeneration in its value container.
  4. Restart initialization so the manager copies the map and Food builds its source whitelist.
  5. Verify the manager exists and Food crosses into Starving during an actual pulse.
  6. Query stamina state/values and compare regeneration. When Food rises above its minimum, removing Starving routes removal of the affect.

Only the source component needs its source-affect flag for this mapping. Destination bStaminaComponentAffects controls outgoing stamina triggers, not whether it can receive a mapped affect. Global bUseCrossAffects is an editor condition, not a reliable runtime disable switch in the current source.

The manager identifies the source map by tag root, looks up the exact key and routes value tags by their CrossAffect destination root. Adding a custom Gameplay Tag alone does not register a numeric effect or automatically emit the source state. See Gameplay Tags and Cross-Affect Internals.

Multiple sources targeting the same affect are not reference-counted. Removing one source can remove an affect still required by another. Avoid overlapping mappings until your maintained implementation handles that case.