Skip to content

06 • Teams & Friendly Fire

Purpose: Demonstrate the mechanics of team-based gameplay and how friendly fire can be handled, including scaling damage between teams and optionally allowing friendly fire.


🧩 What’s in this scene

  • Player (Team 1)HealthSystem with a damage multiplier for friendly fire.
  • Enemy (Team 2)HealthSystem with a separate team identifier.
  • Teams Setup – A simple system to handle multiple teams and apply damage based on team relationships.
  • Friendly Fire – Demonstrates the concept of friendly fire, where teammates can hurt each other if the system allows it.

Components & Features

  • Team System: Defines teams for each character (player, enemies) and how damage is modified based on the team.
  • Friendly Fire: Toggleable feature that, when enabled, allows players to damage teammates.
  • Damage Scaling: The damage applied between enemies and teammates can be scaled differently based on their team affiliation.
  • Damage Prevention: When friendly fire is disabled, damage from teammates is blocked or reduced.

⚠️ Authority Note
This scene runs with Require Authority disabled by default.
Health mutations are allowed locally for demonstration purposes.

Enabling an authority binder alone will not block mutations unless
Require Authority is enabled on the HealthSystem — this is intentional.

Why Health works this way:
https://revandrab.github.io/RevFramework/authority/#health-opt-in-authority-gameplay-state


🕹️ How to use

  1. Press Play to start the scene.
  2. Toggle Friendly Fire:
  3. In the DebugUI, toggle the Friendly Fire setting between Enabled and Disabled.
  4. When friendly fire is enabled, you can damage teammates. When disabled, teammates are protected.
  5. Observe Team Damage:
  6. Apply damage to the Enemy (Team 2) and observe the normal damage being applied.
  7. Apply damage to the Player (Team 1) and watch the damage scaling based on friendly fire status.
  8. Damage Scaling:
  9. When friendly fire is enabled, apply damage to teammates (Player 1). Observe how the damage is scaled by the friendly fire multiplier.
  10. When friendly fire is disabled, damage to teammates will be canceled or reduced to 0.

⚙️ Key Components Used

Component Role
TeamRule Determines if damage is allowed between characters of the same team and handles friendly fire.
HealthSystem Manages health and handles damage for both players and enemies.
DamageContext Holds information about the damage event, including team-based logic.
DebugUI Used to toggle friendly fire and test different team configurations.

💡 Notes

  • Teams: Each character in the scene is assigned to a team (e.g., Player on Team 1, Enemy on Team 2). The system uses TeamRule to determine how damage is handled between different teams.
  • Friendly Fire: By default, the system does not allow friendly fire (teammates can’t damage each other). Toggle it in DebugUI to test the effect.
  • Damage Scaling: When friendly fire is enabled, damage between teammates is scaled by friendlyFireScale. This allows nuanced team-based damage logic.
  • Team Logic: If the attacker and target share a team and friendly fire is disabled, damage is blocked or reduced. When enabled, damage scales via the multiplier.
  • UI-free: This demo uses the DebugUI for interactions; no traditional HUD is required.

⚙️ Key Interactions

Interaction Behaviour
Toggle Friendly Fire Enables or disables damage between teammates.
Test Damage Scaling Observe how damage differs between teams when toggling friendly fire.
Friendly Fire Prevention When off, teammates are immune to each other’s damage.

🧠 Key Idea

Friendly Fire Logic: Managed via TeamRule and controlled through the DebugUI.
This setup demonstrates how team-based damage relationships can be easily extended or customized.


🧩 Demo Notes

  • The panel may auto-add a TeamRule if missing, to keep the demo functional.
    In production, add and configure team rules directly on prefabs.

🔢 Rules Order

  • TeamRule runs early in the damage pipeline (priority ~40).
    This ensures friendly fire checks occur before crits, armor, or affinity.
    Invalid team hits are cancelled at the start of the pipeline.

🧱 Debug vs Production

  • The IMGUI panel is for debugging only.
  • For shipped games, build your own UI and team assignment workflow.