Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How to design such functionality in ECS

Discussion in 'Entity Component System' started by Bagazi, Aug 27, 2023.

  1. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    609
    For instance, in an RPG game, the player controls a warrior wielding a sword. When the player commands the warrior to swing the sword, the character plays the corresponding swinging animation. If the sword makes contact with an enemy, it deals damage and applies effects based on the player's skills. For example, if the player has a skill that causes stun, the enemy might become stunned. Similarly, if an enemy swings their sword at the player, the system checks if the player possesses skills like damage reflection.

    My initial thought is to utilize colliders for implementation. For instance, activate the collider at a specific animation frame (e.g., the first quarter of the swinging animation). However, this approach could face challenges. For instance, with an organic creature's melee attack, like a creature capable of biting, a collider might need to be placed specifically at its mouth.

    Additionally, regarding the computation of bonus effects mentioned above, it might be suitable to have a dedicated system for handling them.

    As for an RPG's combat system, based on theory and experience, would it suffice to manage it within a single system?
     
  2. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,078
    Hey @Bagazi

    I don't think super accurate collision detection is really needed. Most games use simpler methods like Ray/Shape Casts for attacks, such as a sword swipe.

    Usually, RPG games use a Skill/Ability system for special attacks and effects, but it depends on the game itself.

    Unfortunately, Unity doesn't offer a solution for this, but you can check out Unreal's Gameplay Ability System documentation and resources to create your own implementation using DOTS.
     
    Bagazi likes this.