Adding Effects to our player

Creating an swing effect for our player attack animation

Now that we have our swing animation, we can spice it up by adding some visual effects during the animation sequence. We will be working on how to create an new animation state and working with the player Animation script to toggle the animation trigger.

Arc Effect Setup:

First we are going to import and slice the animation sheet into individual frames. Drag the first frame into the hierarchy and make the first frame a child of the player game object. Then we are going to create a new Animation for the Arc effect and dragging in all of the divided images into the dopesheet.

Next in the Animator window we need to create a new default state to prevent the sword arc effect to play immediately after launching the game. We need to create a new Trigger parameter to toggle the transition between the Idle and Sword Effect.

Player Animation script:

In the player animation script, just like how we have reference the animator in the sprite object, we need to do the same for the sword effect.

In the Start method, since both the sprite and the sword effect are children of the player object, we can’t use “Get component in children” anymore since there will be a confusion between the two game objects. Therefore in Unity, we can use an new type of identification. Since everything within the Hierarchy is based on a “hierarchy” we know that the first component is rated at Zero, and the next object starts at 1. Since the “Sword_Arc” component is second in the list, we can type out “Transform.Getchild(1)” before we get the component.

Finally during the attack phase, we can also implement the arc animation as well.

Now when you attack, there should be an sword effect that plays along with it.

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

High-level programming of MCU periphery from a host PC without using firmware and processor. Intro.

Important Points You Should Consider Before Opting For A Web Hosting Plan

Identifying what OS you’re app is being presented

Refresh PowerBI dataset with Microsoft Flow

Boost your productiveness with these 4 Intellij tips

Why you should learn configuration blocks in TIBCO Spotfire

R&D Updates | Oct 2021

Lexical Morphology — Affixes | Between the Lines by English Forward

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

More from Medium

Enabling Unity Ads

Using Post Processing Volumes in Unity3D with the URP

Using Decals in Unity

How to spawn the player object in a platformer game in Unity