Setup Animations - UNITY 3D RPG COMBAT SYSTEM using FSM & Input System (pt.1)

Setup Animations - UNITY 3D RPG COMBAT SYSTEM using FSM & Input System (pt.1)

Introduction

In this video, the presenter shows how to make a combat system using finite state machine and the new input system from Unity.

Setting up Player Actions and Animations

The presenter sets up player actions and animations for the new input system.

  • Add a new action called "Draw Weapon" of type button with trigger behavior set to press only. Bind it to the R key.
  • Create a new action called "Attack" and choose pop listen mouse left button.
  • Download Pro SWAT and Shield Pack from Mixamo. Import them into Unity as binary format with T-pose keyframe reduction set to none.
  • Select all animations in import menu, go to rig animation type humanoid avatar copy from other avatar, and choose whiteboard avatar.

Setting Up Animations in Finite State Machine

The presenter sets up animations in the finite state machine.

  • Create a new layer called "Combat Layer". Set blending mode to overwrite and create an empty state called "Default State".
  • Use two animations for player draw sword/weapon: "Player Draw One" and "Player Draw Two". Set back into position based on original for rotation (x,z,y position).
  • Rename locomotion blend tree from base layer as "Combat Blend 3".
  • Change first state of Combat Blend 3 with player combat idle animation. Rename it as "Player Combat Idol".
  • Add two more animations for player to pull weapon back: "Sheath Sword One" and "Sheath Sword Two". Set back into position based on original for all three cases.
  • Replace player idle animation with player combat idle animation. Make a transition from "Player Draw Two" to "Combat Blend 3". Set exit time when draw weapon is clicked.

Conclusion

The presenter concludes the video by showing how the animations work together in the finite state machine.

Creating a Combat State

In this section, we learn how to create a combat state and trigger it using player actions.

Creating Transitions Between States

  • Bake the pose based on the original and click apply.
  • Drag and drop player sheet 1 and 2 into the animator.
  • Create a transition between states.
  • Apply the sheet weapon condition to the first transition.
  • Set exit time to 1 for the first player sheet one animation in the second transition.

Defining Player Actions

  • Open up our state script.
  • Define drop weapon action and attack action using character.playerinput.action and name of action defined in player controls.
  • Trigger draw weapon action in handle input function, set draw wrapping to true in logic update function, change state to combat state, and trigger draw weapon trigger on animator.

Creating Combat State

  • Create new combat state script with sheet weapon boolean defined.
  • Instantiate an instance of the combat state like other states.

Instantiating Weapon Model with Animation Events

In this section, we learn how to instantiate a weapon model with animation events.

Conclusion

  • If you have any questions about this tutorial, write them down in the description. The creator responds to every single question. Don't forget to subscribe so you don't miss the next video.
Video description

In this video I show you a Third-Person Combat System using the Finite State Machine (FSM) and the New Input System from my previous Video. https://www.youtube.com/watch?v=QVxvwRAYeHU In the first part we setup the Player Actions for the new Input System, import and setup the animations and finally integrate them in the Finite State Machine. Link to the second part: https://youtu.be/9ytQK2QFRQo Timestamps: 0:00 Intro 0:41 Setup Player Actions 1:18 Import Animations 2:00 Setup Animations 7:06 Integrate in the FSM 8:54 In the next Video :) 💾 Source Code: https://pastebin.com/u/JojikYT/1/4YYkmKJk Resources: ✔ LowPoly Trees and Rocks: https://assetstore.unity.com/packages/3d/vegetation/lowpoly-trees-and-rocks-88376 ✔ Animations & Character Model: https://www.mixamo.com/#/?page=1&query=pro+sword Music by TeknoAXE: Synthwave G - https://www.youtube.com/watch?v=XNmQsvOtD3s Anthem for Tomorrow - https://www.youtube.com/watch?v=2JdmOJfwe4c