This style of dev blog will be meant to be kind of half tutorial, half you the reader following along with my thoughts along the way of developing this VR game.
Right now I am about a month and a half into designing this new ice map.
The ice map is meant to be the first in a series of dungeons, which offer something a bit different than the open world ‘overworld’ part of the map. These dungeons are meant to be linear experiences that offer the player a high challenge in terms of density of monsters, offer some puzzles, and ideally introduce a new item/mechanic as a reward for the player progressing.
The challenge right now for this section of the blog is designing trigger box logic for various encounters on the ice map.
Let’s dive into the sequence of events now:
- Enter the map.
- See the dragon near the cave entrance, have it shout some menacing things at you.
- Fight your way down the ramp until you’ve activated the first respawn point.
- Fight your way through three sets of monsters to activate three puzzle platforms which allow you to control giant eye towers and point them towards the ice door.
- Unlock the ice door finally and fight boss dragon in a boss battle.
First we want the player to descend the mountain and encounter enemies along the way.
This part is easy-we put some trigger boxes (green squares) and each time the player overlaps with them, we have them spawn enemies. We implement a do once node, and if the player dies we should reset this node as part of the death sequence so enemies can spawn again: we’ll get to this later.
When the player reaches the final end of the ramp, we want them to unlock a new respawn point.
Open questions: should they unlock this respawn point only if they’ve defeated all enemies? What if they don’t go towards it and teleport off the edge somehow?
To solve for this, I decided to implement either a magic cylinder that draws to this point in the sky so it signals clearly to the player they need to go there to progress or a line drawn from the player’s hand towards this goal. I’ll add this implementing to my todo’s at the bottom of this post.
We want the player to now see an event take place where these eye towers come out of the ground. We also spawn monster portals and/or boss monsters along the way near these towers.
These towers are controlled by this platform with a VRLever the player can spin.
This platform should only be unlocked once the player has beat all the monsters. If they die in the process of fighting the monsters, they should respawn at the last respawn point.
OK–so how is this all achieved in code?
Spawning Monsters–handled by the respawn pad blueprint:
Relevant functions: SpawnNextMonsterEvent–this gets called in one of two scenarios, either the player has survived and finished the previous puzzle, or the player has died, then when the player ends overlap with this wider collision area, it starts the whole sequence again. So only when the player has had a chance to recover mentally and moves themselves again does it start the sequence.
Keeping Track of When to Unlock Lever
This loop is activated after spawning monsters. All monsters spawned or other classes associated with monsters (such as the big spawn portals we create) are added to this array of spawnedActors. Every 0.5 seconds we check if this array is count 0, if not we assume the player has not finished this sequence. If it does tick down to 0, then we destroy the ice cube component of our lever class. TODO: need to draw more attention to this, make sure it’s clear for player they have to go to the lever after they’ve cleared the enemies.
Handling Player Death
If the player dies, we respawn them and destroy all the monsters and return their life back to maximum.
We also have to stop the loop checking for spawned actors before it has a chance to trigger, so they don’t get credit for finishing a sequence just because of monster despawn. This is done by some code in our GameMode class checking to see which map we are on, and then getting a dummy blueprint actor we placed in the level handle all our death logic.
Right now this actor has two responsibilities:
- Reactivate the correct respawn pad so that sequence starts again once the player starts moving.
- Kill all loops respawn pads are firing checking if their clear conditions are met.
So if a player has cleared 2 respawn pads, how do we keep track of that?
Also, if a player quits the game, how we do keep track of which map they should open when they restart the game?
For our case for now we are implementing this fairly simply assuming it’s always the same player and they aren’t selecting their own save game file–later on we’ll have to go back and allow multiple save games so different players can have unique progress.
Right now it is implemented with two variables on the save game: iceLevelHighestTP and currentWorldToLoad.
When the player dies, it gets to this section of logic in the function “RespawnPlayerOpenWorld”. It loops through all the possible respawn objects and gets the one that’s equal to the highestTPNum from the save game. When the player completes one of the puzzles on the levers, then it saves this to a higher number.
Beyond our todo’s, we need to consider the layout for all of these objects in the map. Here you can see the position of the 3 eye towers (all will be under the ground so they have a chance to rise up).
We also have to think about the locations of the towers with the rats operating ballistas and how we want them to respawn. I am leaning towards having them respawn every time regardless of the player location, I want them to feel annoying and not necessarily dangerous but something to keep your mind on. I might add one more rat tower for good measure.
Convert spinner to VRLever Object and test
Implement sound once VRLever object is unlocked
Draw attention to vr lever once it’s unlocked.
Implement sound and animation once final ice door is unlocked
Reset trigger boxes ability to spawn monsters after player death
Implement magic cylinder of great height at first respawn point when that is the player goal or draw an arrow to this point from the player hand.
Sound for eye towers coming out of the ground.
Test travelling to this new level from previous level
Reward waiting: move on to doing ice dragon boss fight behavior logic.