Battle City in Unity Part 15 : Spawning Invincibility
This article is Part 15 in a 25-Part Series.
- Introduction - Battle City in Unity Prequel
- Part 1 - Battle City in Unity Part l: Single(ton) Sole Survivor
- Part 2 - Battle City in Unity Part 2: Level Creation using Tilemaps
- Part 3 - Battle City in Unity Part 3: Creation of the Protagonist and Antagonists(Tanks)
- Part 4 - Battle City in Unity Part 4: Tank Movement
- Part 5 - Battle City in Unity Part 5: Player Controller
- Part 6 - Battle City in Unity Part 6: Enemy AI
- Part 7 - Battle City in Unity Part 7: Creating Projectiles
- Part 8 - Battle City in Unity Part 8: Hurting the tanks
- Part 9 - Battle City in Unity Part 9: Firing the shots
- Part 10 - Battle City in Unity Part 10: The Spawn
- Part 11 - Battle City in Unity Part 11 : The Gamemaker - Starting the Stage and Game Over
- Part 12 - Battle City in Unity Part 12 : Level Manager
- Part 13 - Battle City in Unity Part 13 : The Gamemaker - Spawning
- Part 14 - Battle City in Unity Part 14 : The Gamemaker - Stage Cleared or Game Over
- Part 15 - This Article
- Part 16 - Battle City in Unity Part 16 : Exploding Tank animation
- Part 17 - Battle City in Unity Part 17 : Score Calculation
- Part 18 - Battle City in Unity Part 18 : Battle Status Board
- Part 19 - Battle City in Unity Part 19 : Bonus Crates - Generation
- Part 20 - Battle City in Unity Part 20 : Bonus Crates - Tank Extra Live
- Part 21 - Battle City in Unity Part 21 : Bonus Crates - Tank Invincibility
- Part 22 - Battle City in Unity Part 22 : Bonus Crates - Grenade
- Part 23 - Battle City in Unity Part 23 : Bonus Crates - Stopwatch
- Part 24 - Battle City in Unity Part 24 : Bonus Crates - Level Up
- Part 25 - Battle City in Unity Part 25 : Bonus Crates - Shovel
This will be a short post as it is more about the animation than anything else. You will need an electricity aura sprite like the below for effects.
I will show another way of doing animation - by manipulating its transform.
Start by dragging your
. Also
Then
Now let’s do animation for the Electricity. Go to your Project Window, create an Animation Controller and rename it as PlayerTank. Select your PlayerTank and add an
Open the Animation Window via the Unity Editor Menu(
- Add 2 properties (
Electricity->Is Active ) and (Electricity->Transform->Rotation ) from the Animation Window.
Once added, you should be able to see something like the below.
- Now click on the red circle(symbolizing record). If it is depressed, means we are in recording mode. Check the box for
Electricity: Game Object.Is Active .
- Click on the timeline at point 0:15, you should have a white line that will move to that position. Once the white line is at point 0:15, Set value of
Rotation.z to 90 and ensureElectricity: Game Object. Is Active is still checked.
- Do the same for the above at timeline 1.15.
- Now Click on the timeline at point 0:30, that white line should move to that position together. Once the white line is at point 0:30, set value of
Rotation.z to 180 and ensureElectricity: Game Object. Is Active is still checked.
-
Do the same for the above at timeline 1.30.
-
Now Click on the timeline at point 0:45, that white line should move to that position together. Once the white line is at point 0:45, set value of
Rotation.z to 270 and ensureElectricity: Game Object. Is Active is still checked. Do the same at timeline 1.45. - Now Click on the timeline at point 1:00, that white line should move to that position together. Once the white line is at point 1:00, set value of
Rotation.z to 0 and ensure Electricity: Game Object. Is Active is still checked. - Do the same at timeline 2.00.
But uncheck Electricity: Game Object. is Active Click on the Add Event button as indicated with the Mouse Pointer below.
- A white ribbon(turns blue when selected) will appear just below the 2:00 timeline. And the inspector should come up with the title “
Animation Event ”. Select from the drop-downSetHealth() .
- Now Click on the timeline at point 0:00, that white line should move to that position together. Once the white line is at point 0:00, click on the Add Event button as indicated with the Mouse Pointer below. A white ribbon(turns blue when selected) will appear just below the 0:00 timeline. And the inspector should come up with the title “
Animation Event ”. Select from the drop-downSetInvincible() .
- Click on the red circle symbolizing record to stop recording. Now your Electric Aura is completed. Click on Play of the Animation to start enjoying the feeling of invincibility.
The next step is to set the TankCreating Animation as the default state as this will be the first animation that will play when the tank first appears on the Scene. Then we need to do is from the Animator add another state for the animation to transit to after electricity aura exipres. Open up the Animator Window from Unity(
Right Click on the Animator Window Base Layer and select
Right click on the TankCreating box and select
No new code required
That’s all for the electricity aura effect animation. Remember to save your PlayerTank Prefab. Next post we will talk about the explosion animation when a tank is destroyed.
This article is Part 15 in a 25-Part Series.
- Introduction - Battle City in Unity Prequel
- Part 1 - Battle City in Unity Part l: Single(ton) Sole Survivor
- Part 2 - Battle City in Unity Part 2: Level Creation using Tilemaps
- Part 3 - Battle City in Unity Part 3: Creation of the Protagonist and Antagonists(Tanks)
- Part 4 - Battle City in Unity Part 4: Tank Movement
- Part 5 - Battle City in Unity Part 5: Player Controller
- Part 6 - Battle City in Unity Part 6: Enemy AI
- Part 7 - Battle City in Unity Part 7: Creating Projectiles
- Part 8 - Battle City in Unity Part 8: Hurting the tanks
- Part 9 - Battle City in Unity Part 9: Firing the shots
- Part 10 - Battle City in Unity Part 10: The Spawn
- Part 11 - Battle City in Unity Part 11 : The Gamemaker - Starting the Stage and Game Over
- Part 12 - Battle City in Unity Part 12 : Level Manager
- Part 13 - Battle City in Unity Part 13 : The Gamemaker - Spawning
- Part 14 - Battle City in Unity Part 14 : The Gamemaker - Stage Cleared or Game Over
- Part 15 - This Article
- Part 16 - Battle City in Unity Part 16 : Exploding Tank animation
- Part 17 - Battle City in Unity Part 17 : Score Calculation
- Part 18 - Battle City in Unity Part 18 : Battle Status Board
- Part 19 - Battle City in Unity Part 19 : Bonus Crates - Generation
- Part 20 - Battle City in Unity Part 20 : Bonus Crates - Tank Extra Live
- Part 21 - Battle City in Unity Part 21 : Bonus Crates - Tank Invincibility
- Part 22 - Battle City in Unity Part 22 : Bonus Crates - Grenade
- Part 23 - Battle City in Unity Part 23 : Bonus Crates - Stopwatch
- Part 24 - Battle City in Unity Part 24 : Bonus Crates - Level Up
- Part 25 - Battle City in Unity Part 25 : Bonus Crates - Shovel
s