Game Creation (#4)

It's time to start the process of making my game,  first off i need to set up my map.

So as can be seen i set up my basic walls, these walls are not shoot-able and will make the basic maze. The player is spawned bottom right and he has to make his way over to where the moving tool is being used.

How i set this is up is mostly by used the scale tool on the outside walls and then copy and pasting them as squares, I then deleted the walls that i will replace with destructible walls.

The next thing i did was set up my destructible walls. I did this by create a trigger box and creating a blueprint attached to that, this allowed me to go in to the script and say OnCollision, delete itself.
I then create and object inside of the trigger box viewport, this is the wall that is destructible, i re-sized it using the scale tool and copy and pasted it around the map.
The first sort of functionality I made was the flashlight, I plan to add a roof over the top of this maze and make it darker.

I would like to state that a lot of my functionality comes from that of tutorials from the YouTuber: Virtus Learning Hub / Creative Tutorials. I have never used Unreal before this and never have I ever used BluePrint before. This project was mostly just a learning experience for the most basic things Unreal has to offer.

First i added a new input called Flashlight and set it to the hotkey F.

Next i went to FirstPersonCharacter Viewport and added a spotlight above my camera:

I then went to my FirstPersonCharacter Event Graph and said when the Flashlight input is pressed, to toggle between setting the spotlight to visible and invisible. 
I found a problem though. It toggled on by default, I went to the event BeginPlay function to set visibility to off but it was in use, i then discovered i needed a sequence node in order to use the event BeginPlay to do the original function and the flashlight toggle i wanted.
Next I needed to have a lose condition, I decided it was between a count up counter with the possibility of death in the maze and a count down counter when you have to make it to the otherside before the time counts down. I decided to stick to my original thoughts and have a count down timer and keep the scope small. The worst thing to do during the game creation process is overshoot the scope. You'll be left with either missing functionality by the end of the deadline or subpar functionality that barely works.

This was the first time I'd ever used the HUD and UI inside of Unreal so of course i followed the tutorial videos of the YouTuber previously mentioned. He had some very simple and informative videos on how to go about it. I firstly made a new UI widget and called it PlayerHudWidget, I put some text in the middle and increased it's size.

Next I went to my FirstPersonGamemode BP and created an Int variable called seconds. I set it to on every tick, with a 1 second delay. Minus 1 from second with an inital count of 15. When seconds equals 0 i will show the GameOver hud but i hadn't made that yet. I went back to my PlayerHudWidget and got the text box name, i casted to the FirstPersonGamemode class to get the seconds variable, i then set the text to the seconds value.




I also imported my Gravity Gun and set the model in place of the gun in the FirstPersonCharacter. Although I also needed to go and increase the size of the gun and rotate it a bit in Maya and re-import it because for some reason i was unable to do that in the model editor (it also wouldn't recognise my imports and took me 3 hours to actually get it to import properly).

In my FirstPersonHUD i also went in to the script and added on Event BeginPlay, create the widget which has my PlayerHudWidget with the countdown timer.
Next I needed a main menu. So i create a new level first off, in this level i firstly created a new HUD and a new Widget with my main menu, i then went to the world settings of the main menu level and changed the override settings on what HUD and GameMode to use, i also turned off the pawn class.

The menu was pretty easy actually, quite similar to Unity, although i struggled with how to add text to buttons, it turned out you needed to create a textbox and wrap a button around the text. I used vertical boxes to hold my main menu, options menu, and information screen. Then its quite simply going to the button clicked events and turning the vertical boxes invisible and visible. The functionality for starting the game is simple "Open Level" and level name, and "Quit Game".

The most work i put in to the main menu was changing the tint colours for onHover and onClicked and padding the sides and the tops of the buttons so they weren't misaligned.

The resolution settings were interesting. Turns out you are able to use console commands in the BP Script.






The next thing to do was create pause UI and functionality. All i did was create a new widget and in the widget i had 2 buttons with text for resume and quit. I created a new input called Pause and set it to the escape key. I then went to my FirstPersonCharacter Script and said if the pause key is pressed and the pause screen is off then create widget using the pause menu widget and add it to the viewport.

I ran in to the trouble that my cursor wasn't showing so i had to write something to specifically show it.
I then set the game to pause and set the is screen shown boolean to true.
In the pause menu widget i set the on click of the resume button to unpause the game. Clear the pause widget. Set the is screen shown boolean to false and hide the mouse cursor again.
I now needed a win state and a lose state. I made the lose state but i have nothing to make it show that you've lost. I made a new widget.


On Game Over widget functionality i went to the where i adjust the count down timer, i said when it equals 0 then do something. Well now that something is to remove all current widgets, meaning the countdown widget. and create a new widget which is my Game Over widget, add it to the viewport and set the mouse cursor to active and pause the game.

On Game Win i will do the same thing i did with the destructible walls. I created a trigger box and attached a new BP script where i said when the player collides with this, delete all current widgets, create a new widget which is my Game Won widget and add it to the viewport, then set the mouse cursor to active and set game paused to true.


Now lastly, one of the tasks for the game requires me to use the Geometry tools. So i created some obstables in the map using Geometry and the Extrude tool. I used it on stairs only really as if i tried it on cubes it would just make the shape inefficient as it doesn't need to be extruded usually as you can resize them normally using the Scale tool.





Comments