I'm making a horror game #06

Camera, flash, and temperature

I'M MAKING A HORROR GAME

7/15/20234 min read

GIF showing how the camera works in the project. It flashes momentarily before turning off.
GIF showing how the camera works in the project. It flashes momentarily before turning off.

Howdy!

Welcome to another I'm making a horror game post. On today's live stream, we worked on a couple of things. First, we implemented the camera, which allows the player to navigate the world while also acting as a defense mechanic (more on that at a later date.) Additionally, we added some elements on the HUD to allow easier testing of different variables such as Health, Heartbeat and Temperature. Speaking of Temperature, that's the omnipresent threat in the game - Cold - more on it below. Happy reading!

Staple mechanic of the game, the camera is a multi-purpose tool. I would love to find a way to make it take actual pictures and allowing the player to look through them. Maybe a stretch goal?

As of now though, the camera is a spot light with very high intensity that turns on, then after a short delay, the intensity rapidly diminishes until it is turned off.

The intention with this feature is to not only allow the player to use this to navigate the world, but also to defend themselves against potential threats.

Check the gif on the right to see what it looks like! But how does it work? Well, it's actually pretty simple.

THE CAMERA

In-engine screenshot of the game's HUD elements.
In-engine screenshot of the game's HUD elements.

THE HUD ELEMENTS

There isn't much to say here. Couple of HUD elements to help debug variables as they change throughout gameplay.

They each get their values from a manager component on the player's character. Each value has their own manager.

If you'd like to know how I achieved this, feel free to @ me on Twitter! Who knows, maybe I could make a short tutorial and post it on Youtube.

Unreal Engine 5 Blueprint logic for decreasing the player's temperature.
Unreal Engine 5 Blueprint logic for decreasing the player's temperature.

TEMPERATURE

As with all player stat, Temperature has its own manager on the player character. It is responsible for keeping track of how cold (or warm) they are. Any function that modifies this particular stat lives in the manager component.

Seeing as cold is a danger throughout the game, the logic for applying cold is in the game mode blueprint. I'm thinking of putting it in the level blueprints, that way each level can have a different intensity. We'll see how development goes.

Having the cold part of things controlled by a higher-level blueprint means I can focus on placing heat sources as opposed to both (as suggested by a twitch viewer.)

So far I managed to create the basic logic for the heat sources. Some can be turned on permanently, others on a timer, whilst others require an item to be turned on.

Once turned on, we check if the player is in range. If the player is in range, we give them protection from the cold and increase their temperature every few seconds.

When the player reaches a cold temperature and stays cold for too long, something bad happens. The next part is going to add something when the player is too hot, just because it would be weird to have a player go to 50 degrees.

Unreal Engine 5 Blueprint logic for a flash-like spot light.
Unreal Engine 5 Blueprint logic for a flash-like spot light.

The first step is to set our spot light's intensity to a crazy value (I'm talking like... 200,000). This ensures that it looks like a flash. Of course, the next step would be to turn it on, so we set its visibility to true.

You can see in the screenshot on the right there's also a boolean variable for "Is on cooldown". This gives control over how often the player can trigger the flash. Seeing as rapid flashing is an accessibility concern, I highly recommend having some form of limitation to prevent any discomfort or seizures. Keep in mind the player may be streaming, so thousands of people could be watching.

Unreal Engine 5 Blueprint logic for a lingering spot light.
Unreal Engine 5 Blueprint logic for a lingering spot light.

After we set the visibility to true, we add a small delay before out timeline, which will control the flash's lingering intensity.

The timeline has a float track which controls the intensity from maximum (200,000) to 0. In the update, we set the intensity of our spot light so it decreases according to the timeline.

Once the timeline is over, we simply turn off the spot light. There, you have it! Your very own camera flash using a simple component and a couple of Blueprint nodes.

Unreal Engine 5 Blueprint overview for a heat source actor.
Unreal Engine 5 Blueprint overview for a heat source actor.

That's all folks!

If there's any particular part of this you'd like a more in-depth look at, let me know through Twitter or Ko-fi.

I'll see you for part #07!