Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question What is the best aproach to a character with multiple weapons?

Discussion in 'Animation' started by expcalibur, Jul 3, 2022.

  1. expcalibur

    expcalibur

    Joined:
    Nov 3, 2020
    Posts:
    25
    Hi! I'm making a survival 3D game where the character will have melee and ranged weapons. So I would like to know what are the best solutions to making all the animation sets for the different weapons. For example, if I have a melee and ranged weapon, how do I change the animations between the normal unequiped animatons? I thought of using one blend tree for each, and swapping between them, but I don't know if it is the best one to use.
     
  2. Flipperyon

    Flipperyon

    Joined:
    Mar 15, 2017
    Posts:
    2
    Hello!

    The approach i'm using is boolean based, like "SkillXEquipped" in the animator itself as a parameter, connecting the condition to the boolean, and the code activates this boolean based on whatever condition is needed to use the weapon/skill. Also, use sub-states for different types of weapons, because Blend Trees will blend one weapon attack with another, causing a mess. In my experience, you should use blend trees only with interchangeable movements that depends on simple parameters and are very similar, like Walk>Run or a 8-direction strafe. So, if you have 3 different types of attack, use 3 different states and make transitions between then.

    So, for example: If the character is equiped with a Heavy Two Handed Mace, the parameter "Heavy 2H Mace" is true in the animator at all times. If the player have the upgrade "Skill 1", and press the skill input, this triggers the "Special 2H Heavy Mace Attack" animation in a Sub-State "Attacking", because it meets the conditions.

    You can also use this to make things like a sub-state with Heavy 2H movement (heavy walk cycle, low jump, fat roll, etc) and a inner sub-sub-state with the weapon specific attacks, like Heavy 2H Odachi, or Heavy 2H Warhammer.

    Maybe there is a methodical and string-based solution with ultra optimized coding that solves the need to hard-code in the animator all the conditions in all the possible transitions, but to be honest i'm not clever enough. I'm making a 3D Platformer/Metroidvania with fairly complex movement, with colliders dynamically changing booleans all the time and everything works perfectly in this way:).