Project update: Coin Distraction

Andrea Alicino
2 min readJun 3, 2021

Lately, I’ve been focusing a lot on guards and their behavior. Now I need to write a system for overcoming them and being able to move on.

The objective is to distract the guards so that we can move on to the next area undisturbed. We toss a coin and the guards hear the noise and go to check.

we start by dividing our problem into sub-problems:
- spawn a coin
- capture the attention of the guards
- make them go in the direction of the coin to check
- check that everything is working properly.

Spawn a coin

We exploit the same system we used for the movement of the player, we take the final position through the main camera using a ray cast.

Add an audio feedback representing the coin falling on the ground.

Capture the attention of the guards

To catch the guards' attention, we need to write a method that tells the guards the location of the coin.
With the function “FindGameObjectsWithTag” we can find all objects in the scene with that tag. In our case “Guard1”.

this method finds all the objects in the scene with this tag, pay attention to the tags you assign.

make them go in the direction of the coin to check

Now that we have found all the guards and inserted them into an array, it is time to call the components we need to communicate that a coin has been flipped, its position and to activate the movement animation towards the coin.

We also manage subsequent conditions in the guards and check for abnormal behavior.

check that everything is working properly.

Now let’s test that everything is working properly.

And there our problem not easily explained to a computer has found a solution in many small problems easy to calculate.

--

--

Andrea Alicino

Game Developer Unreal Engine/Unity. Computer science graduate. Seeking new opportunities.