Making a hunter

Without danger I think our game would fall flat.  It’s not that fun flying aroud in the darkness without some tension. from the start we said that there should be at least three enemies in our game and we started off by makinig the hunters. I wanted everything in our game to feel alive and therefore i didn’t want the hunters just standing in one position.

Idle state
At the start of a new game, the player is not close enough to get the attesion of a hunter. The hunters are therefore in the Idle state. They are big hornets that gets provoked if you fly to close and who find interest in lightsources. They are moving around in certian areas and are always able to surprise the player from a new angle. They wouldn’t feel alive if they were always standing in the same position. In the Idle state I have made so that they can move around freely within a radius from their starting position. Every few seconds the hunter changes its direction and speed randomly and if the hunter is on its way outside the radius it turns back toward the center of its movement restrictions.

I have made a timer that counts down every frame to determine when the hunter changes its direction. When the timer hits zero, the hunters’s new movement direction is determined by a randomly made angle and a random float between one and three is made as a multiplier for the speed. The movement speed is created by adding a force to its rigid body with fixed update. This could potentially make the hunter accelerate forever, if there was nothing to slow it down, but to counter that acceleration I am using the linear drag already built for Rigidbody 2D in Unity.

Chasing state
If the player, child or light source is close enough, the hunters’s state will change to the Chasing state. In this state the hunter follows its prey blindly, but even though it is moving faster than it does in its lost state, it is still not as fast as the player, but it may catch up to a child. If the player flies too far ahead of the hunter it will go back to the Idle state, but switch out the starting position for its current position.

Sound
The hunters will later be able to make specific sounds matching the state they are in. How often they make these sounds will also be determined by each state, but the volume will be determined by the distance to the player.

About Sebastian Wallin

2016 Programming