informa
2 min read
article

Using Unity Animation Events: Deterrence - Video Devlog 13

The thirteenth weekly devlog of Deterrence. This week I use the unity animation events to make enemies deal damage and spawn enemies for levels. And the project starts to feel like a game as pieces come together.

A tower defense mixed with real-time strategy where you repel attacking sentient AI robots until they give up.


Using Unity Animation Events

Since the enemy robot's animation shows the unit firing twice, I decided to also use events for each fire animation that would call the enemy unit's fire method. This gave me a lot of wiggle room to make units shoot in different ways and also made it very simple to calculate unit DPS (Damage Per Second). So, I decided to make player units follow this structure as well.

Calculating DPS using Unity animations required grabbing the RuntimeAnimatorController of the units Animator. With the RuntimeAnimatorController, I can find the fire animation by name and then simply use the animation length and number of events in the animation.

Unity animation event functions don't support methods that have multiple parameters, so, to get around this, I made a method with a string parameter and pass multiple parameters separated by a comma in a large string. With this trick, I can use animation events to spawn diverse enemy groups at any start point in the level. Doing it this way will make it easier to build levels by using the animations like event timelines and using the extra functionality that comes with animations.

Starting To Feel Like A Game

Now that enemy units can deal damage to player units and buildings, and can move towards points of interest; Play testing is now starting to feel like playing a game. I'm starting to balance stats and list of functionality to implement is dwindling. The game is approaching an alpha stage and by my estimate I believe there will be an alpha version of the game within the next 2 months.

Latest Jobs

Treyarch

Playa Vista, California
6.20.22
Audio Engineer

Digital Extremes

London, Ontario, Canada
6.20.22
Communications Director

High Moon Studios

Carlsbad, California
6.20.22
Senior Producer

Build a Rocket Boy Games

Edinburgh, Scotland
6.20.22
Lead UI Programmer
More Jobs   

CONNECT WITH US

Register for a
Subscribe to
Follow us

Game Developer Account

Game Developer Newsletter

@gamedevdotcom

Register for a

Game Developer Account

Gain full access to resources (events, white paper, webinars, reports, etc)
Single sign-on to all Informa products

Register
Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Subscribe
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more