The Defender gets in Shape

The past weeks, we struggled to identify what the Defender should be able to do, what would be fun, how much gaming knowledge we could anticipate from the target group and what fits into the scope left. Gladly, we do have a detailed answer to almost everything, now. And because of this reason, mostly everything was related to the Defender, this week. But first things first, I will quickly go through some minor tasks:

Little Things

The billboards that represent every actor in the game for the Defender on his mobile screen caused some trouble. There is only one billboard assigned to every actor, but often, there was more than one displayed or it switched the texture to a random other already used by another actor. Sometimes, it switched appearance with every shot the Attacker does and nothing was clearly reproducible. To that day, every actor had its own blueprint component and a way to update the location.
To simplify this problem, I created a new central blueprint. This one was only about the billboard component and the tick event, that moves the location of the billboard on top of its assigned actor. Each actor just spawns that blueprint and assigns itself towards it. It turned out to be very convenient to work with, but did not fix the initial problem.

Another simple request by the designers got fulfilled: If the Attacker falls down a platform into the unlimited depth, he should take a little damage and gets teleported back to his spawn point.

Daniel implemented the health bars and health regeneration for the Attacker and I adapted his code to also take other actors into account. Every drone, the mainframe, and the generators have health bars, now.

The drones slightly hover over the ground from now on. It is a tiny procedural animation that offsets the drone’s model towards its parent with a smoothed out interpolation function.

Gina finished her first iteration of Grapple animations. Daniel implemented the model and functionality already, all that was left to do was the Animation Blueprint, and as I had some experience with Unity’s Animation Controller, I created a little state machine that drives the animations.

Some UI elements got some attention regarding their scaling and the health component was spamming the Output Log.

Defender Gameplay Improvements

To prevent the Defender of spamming drones, I developed a simple mechanic that tracks the number of drones currently in the level and denies to spawn additional ones if the limit is reached.

Rebecca asked me to do a little change to the way I spawn the drones. After selecting a drone type, instead of just hit execute, spawn the drone right away and start its behavior, she liked to have more control over the location the drone will investigate first. Actually, it should be a “drag & drop” action: selecting the drone out of the list and drag that drone to a location its should move to first. To implement it more quickly, I skipped the drag & drop part, as it seemed a bit more complex to detect a UI button and do a line trace later to get the actual location. In Unreal, the Mouse can either be “locked” in “UI-Mode” or in “Game-Mode”. In the first one, it can only interact with HUD elements, in the second one, it can only interact with the game world. If you want to use both, which is possible, you either have to hold ALT to switch between the modes, or double-click on an element (the first click will switch the focus, the second one will be registered as an action). I expected the same behavior for the touch input and to remove the complexity of having to use both modes at the same time in one action, I stuck with two simple touch actions. The first will select the drone out of the UI and the second will trigger spawning and handing over the current touch location to investigate it first. That also included some failsafe code, to prevent the Defender from touching outside of the world as his second touch, etc.

The Generators got a new look and became the main pillars for the Mainframe’s shield. The Mainframe is surrounded by a shield that protects it from any source of damage. This shield is active as long as there is at least one Generator with at least one health point left.

The Generators’ and the Mainframe’s health point UI element got replaced by a health bar.

Defender’s Generators’ Abilities

Until then, the only thing the Defender could do was to wait for energy and invest it into drones. To add more depth to his gameplay, I converted the designers’ concept of abilities for the generators into code. Clicking on a Generator opens up a new menu. He now has two different options: a blast and a shield. Clicking on one of the options will execute it, but will also trigger the ability’s cooldown. The corresponding button is therefore deactivated until the cooldown is over. Each of the abilities consumes energy by execution, also. The blast is some kind of energy explosion around the Generator and sends out multiple projectiles in a random direction. The shield just holds for x seconds and the Generator becomes invulnerable during that timespan.

Defender Energy Pickups

It was a design choice to remove the Carrier Drones, the one which delivers energy to the Mainframe, from the project. They should be replaced by “Energy Pickups”. The old system doomed the Defender to just look at the screen and wait for the energy. The new system should involve the player a little more into that process. This time, the Generators themselves produces the energy. It is symbolized by energy icons that appear near each of the Generators. The Defender can pick them up by touching and this will also trigger a timer to respawn these pickups with a little help of randomness. Each generator does only have one regular pickup at the same time, so the Defender must pick it up to generate another one. The Generators produce another sort of pickup while being hit from the Attacker. These are smaller ones and does not respawn but they add up and should counterbalance the actions from the Attacker.

It took me ages to figure out how to calculate a position near the Generators to spawn the icon. At first, I was sure that I had to calculate some form of circular math, but in the end, it was straight the Pythagorean theorem to get every icon on a circle that surrounds the Generator and is defined by its radius. Obviously, this is another proof for my lacking practical mathematics knowledge.

In preparation of upcoming tasks, I created a little “XP and Level Up System”, the XP Component. The Defender gets experience points equivalent for ever damage points he does to the Attacker. And each level consumes different amounts of that XP to create “Upgrade Points”. These should be spent later on a Skill-Tree that will follow next week.