So after part 1, I had the bare bones of a slenderman game. In this part I wanted to flesh out the mechanics a little more and make it start to look more like a "game". My Goals for part 2 were:
- Replace the cubes with actual "notes"
- Create random spawn points for the notes
- Create a sprint mechanic + realistic jump
- Add sprint and notes to HUD widget
- Change it to night time
- Create a flashlight
- Create a battery mechanic
- Executable
1. Replace the cubes with actual "notes"
2. Create random spawn points for the notes
For this I opened up blender and made the shittest piece of paper. Took about 1 minute. Made sure to resize the plane to A4, curled the edges slightly and gave it a material slot for the front and back and then exported it to Unreal.
I downloaded the note textures used in one of the slenderman games off google images and created materials from them. Then created a way for the notes to pick one of the materials at runtime. There are 8 different textures and each note is unique:
I created a new blueprint which now handles the spawning of the notes and what material they get. This blueprint contains 16 locations where the notes could spawn. More can be added but only 8 locations will be picked at runtime. You can change the number of locations in the details panel in the editor.
3. Create a sprint mechanic and realistic jump
Default unreal man jumps like Princess Peach; in fact it's more floating than jumping and greatly annoys me. Fixing it is quite simple though by just changing the Z Jump Velocity in the Character Movement.
The sprint mechanic is also relatively simple. When shift is held, it reduces the sprint each second and when it reaches 0 (from 100), you can no longer sprint. It takes 10 seconds to replenish fully. I achieved this by using timers instead of ticking. That way, we're not constantly checking to see if we're sprinting (or replenishing sprint value) every frame; only when we need to.
4. Add sprint and notes collected to the HUD widget
Using icons from the Android library (they're free to use) I added a progress bar and text to the HUD:
The progress bar does use a binding to update itself which is expensive but barely anything is ticking in this game so I didn't really care. In UE5, the progress bars now come with a default animation as well which is snazzy. The notes text is updated when a note is destroyed and the blueprint sends a message to the HUD.
5. Change to night time
This was one of the most difficult parts as lighting in Unreal Engine is unbelievably difficult. You need to change colours determined by sun, override sky colours, change the post process volume and exponential height fog....it's never ending. Also, as the scene is so dark afterwards; I duplicated BP_Sky_Sphere so I could add a tick box which would allow me to switch between day and night in real time.
In the construction script I added this mess:
6. Adding a flashlight
For this I simply add a spot light to the character and attached it to the head socket so it moves with the character. I thought about a doing a torch you hold in your hand but couldn't be bothered with the hand animations as this is true first person so instead, the player is wearing a head torch. I added some nodes to allow the player to toggle the flashlight on and off with F.
7. Adding a battery mechanic
This didn't take long as it was almost copy and paste on the sprint mechanic. I added some timers to the flashlight so when it's in use it begins to lose power and it updates the HUD with the new power level. I added a cylinder to game which acts as a "battery". When you pick it up it replenishes the battery power; regardless of how much power you have left. So batteries should be used wisely as you can't store them in an inventory.
8. Executable
In the gif, "slenderman" is motionless as I disabled it's "AI" for the moment whilst testing (and I forgot to remove the debug output from sprinting) but it's starting to look more like a spooky game now!
No comments:
Post a Comment