Previous --- Next

Index

Something That Shoots You

In order to add a new gameplay element that would be relatively fast to develop and add a new dynamic to the game, it was suggest that I add a turret-like enemy to the game. Since the area the game takes place is some form of abandoned alien mining facility not, for instance, any sort of military area the turret-like enemy had to be organic, somewhere between animal and plant like the Tentahex enemy previously mentioned.

The idea behind the gameplay implications of this turret-like create were that to force the player to occasionally take cover behind some of the scenery and also have areas where the player has to keep moving to avoid getting hit.

There was a need to implement this enemy as swiftly as possible due to a fast approaching deadline. Therefore the functionality was established first, and the visuals based around it. The enemy uses the same scripting as the Tentahex enemy with a few modifications, most of which were changing variables to increase the range at which it detects and attacks the player. Otherwise, a new function was required for the shooting itself. Basically, it calculates the direction to the player, then spawns a projectile at the centre of where the “head” of the creature should be. The projectile spawned uses Unity's rigidbody dynamics, and propels itself forward once spawned. To ensure that the projectile travels towards the player in a straight line (this was to avoid having to work out a trajectory to fire along based one distance and parabolic curves and other technical... stuff) the projectile is not affected by gravity until it has been flying for a certain amount of time, after which it starts to fall. Without this, the projectiles would either have to be fired with a ridiculous amount of force, or have a tiny amount of mass, neither of which produced desirable results.


When the projectile hits something, it spawns a small splash-like particle effect. If the projectile hits something with the tag “world”, this is all that happens. If it hits something tagged “Player”, it access a PlayerStats script attached to the player, and executes the ApplyDamage function of that script.

This all worked fine and dandy, but there were still a couple of issues. One was the the turret enemy would continuously fire at the enemy if it was in range, regardless of whether there was a rock, a wall or a hill in the way. Another problem was that it would shoot at the player with a regularity that was both monotonous and either too hard if the fire rate was high, or too easy if it was low.

The solution to the first problem was to have the enemy perform a raycast towards the player whenever it tried to shoot, and if that ray hit anything other than the player, not shoot. (This itself had the minor issue of it considering that it's own projectiles were blocking the ray, but it only really happened if the play stood still. Plus it nicely tied in with the next solution)

The second problem was solved by writing a few lines of code to make the enemy fire the projectiles in salvoes, the amount of which was randomised within given constraints. This, combined with an accuracy multiplier to give the spawned projectiles a small amount of spread, gave the turret enemy just enough randomness to make it seem much less mechanical and a bit less predictable, while ensuring there was a pattern to the attacks with a constant time between each salvo fired, giving the player an opportunity to hit it with a Space Machete or run past.


Now that all that boring stuff is out of the way, this is how I made it look pretty:

Since the nature of the implementation of this turret-like enemy was time critical, the art for it was also. Since I knew vaguely from the scripting and playtesting the sort of size and locations it would work in, I had an idea of the proportions for the creature. I also knew that I couldn't have some sort of spout or cannon-like feature to point at the player and fire out of, as it would have required further scripting and testing.

So, the idea was to essentially have a sponge-like ball on top of a stalk. The stalk, of course had to be hexagonal like everything else in the world, but the head is a ball. A ball with holes in.

This ball with holes in head was swiftly constructed by creating a sphere, then creating a bunch of other spheres on the surfaces, carefully lining up the geometry, then perfoming a boolean operation to cut out the holes. The geometry would be terrible for deforming, however I wasn't intended on there being any so it would do just fine. As the UVs for the sphere would cause noticible pinching at the top, I added a small stalk to cover up that area.

The texture work was also produced quickly, although was probably the aspect of this asset that took the most amount of time.

Again, the texture is largely based on elements of the world, particularly that of the basalt-like columns. The only differing aspect is further use of the self-illuminated shader to make the holes glow green. Another running theme with this game is that green glowing stuff is apparently bad for you and that you should avoid it.

One more element of the texture was to add a few stains of green gloop on the sides where it has leaked out of the holes. These stains also glow.

Just in case the above description of these enemies is not clear enough, here are two pictures. One taken at night to prove that the glowy bits glow.



With the turretish enemy present and functioning in the world, it was time to place around a few different spots to have a notable effect on gameplay. Much more consideration was put into how and where these particular enemies were placed as opposed to the Tentahex enemies, which largely fulfil the role of Something To Hack Because It Is In Your Way (that can also hit you. Like an angry bush).

Following is a breakdown of the main areas these enemies are placed and the reasoning behind:


This is potentially the first encounter the player will have with the projectile enemies (there is a main route through the level, which can be taken either way, however it is fully possible to not follow the obvious and planned pathway).

Here the player will be climbing up this hexagonal staircase, while being bombarded from above the the turret-like enemies. As long as the player doesn't sit still, it is perfectly feasible to make it to the top without taking any damage (in fact it's possible to complete the whole map without taking any damage, with a bit of luck).

This creates a sense of urgency for what would otherwise be a simple exercise in tapping the jump button.

 


This next part, if the player doesn't Space Machete the turret enemy on the left requires the player to swifty ascend the tube, while possibly taking cover from any incoming projectiles. There are two routes to access the tube, one of them longer, but with considerably few enemies able to attack. Considerably fewer means none.

 


Here the player has to secure a piece of the ships cannon that is hanging over a precipice with a drop into a lake of green goo that is, of course, glowing and dangerous. It is also within range of the boss-type turret enemy, that will fire projectiles if you linger at this spot too long. This hopefully establishes that the boss-turret is not something to get near as it will unleash green, gooey fury upon anybody who gets too close. Unfortunately it probably looks more like a tempting target, and isn't actually that dangerous. It's a good job the boss-turret was easy to stick in. Insert normal turret, increase the scale and crank up some variables. Then stick in a modified projectile that hits harder, hits faster and is, of course, bigger. It's purpose is more to establish a landmark and look imposing. Still, it hurts if those boss-projectiles hit you.

 


Here, the player has to pass over a large scaffold-like structure. Care must be taken to both avoid falling off (which should technically be lethal, but it does not always work) and the projectiles fired from the enemies hanging beneath, which can sometimes push the player on contact.

These hanging enemies also have a line of sight into the entrances of the tubes on either side, so idling around those areas is less than ideal.


This area here was initially designed to be a spot for an arena or boss battle, however I ran out of time to script any sort of enemy to make that work. So instead, when the player reaches the top of this large rock, not much happens as I placed all of the enemy turrets out of range of the tube exit and forgot to extend their rangers, so only a couple manage to get a shot off as the player heads towards the cannon part placed precariously on the edge, next to another fall that should, in theory, be deadly.

The only particularly interesting turret placement up here, now that most of them are uselessly out of range, is the one on the bottom right, which bombards the player with goo-balls as they traverse down the tube (or up, if you're playing backwards). More around this area shooting at the tube would have been a good area, but would have been too similar to the next encounter...


This here, is the gauntlet. An epic run through a barrage of little goo balls as you race back to the ship.

Unless you're playing backwards, then this is the first thing that happens and the whole this is a bit anti-climactic. Or if you miss a turret piece, and have to backtrack to somewhere, then this is in the middle. This is an open world game. It has an epic ending if you want it to.

Anyway, that is basically what this stretch is designed to be, a gauntlet, where if you stop running, or want to go back to pick up your hat, you can't. Well you can try, but you will end up with a face full of green glowing goo balls, and we have already established that this is not a healthy thing.

Lastly, a brief word on the animation for this amazingly long section about a ball on a stick that shoots out little balls of goo.

The animation for these enemies is not skinned or joint based, it was animated by keyframing a rotational transformation on the head object, then importing that into Maya (Unity imports bones as transforms anyway, so it had exactly the same result, just without the added hassle having to skin the model).

As with the Tentahex enemy, three basic animations were developed, and like the Tentahex animations, they were kept short and simple as one of the main functions of the animation here is to convey what state the enemy is currently in. The same animation types were included here, as the script is largely identical to the Tentahex script, and the animation names are the same.

This idle animation is mostly there to avoid having the turret sit stock still, so the head movement is somewhere between swaying in the breeze and tapping it's foot (head) in boredom.

The alert animation performs a similar function the that of the Tentahex, the turret violently shakes it's head area as if to warn whatever is getting close to stay away.

The attack animation is designed to imply that the turret is juddering as it fires the goo balls. As it stands, the animation probably does not convey this quite as well as I intended, especially as the alert animation looks far more aggressive, however for all intents and purposes, it works and it almost has the effect of the turrets focusing to aim at their target.

For a demonstration of the turrets going through their animations and states:

Previous --- Next

Index