We was asked to make a game for living coast we set up a group so we all had a job to do, for our game we wanted to have a HuB menu where all the characters of the game would be sitting in a pub and each character would have their own game adding up to 4 different games. unfortunately, due to time we weren’t able to do all the games and settled on doing the one which is a penguin endless runner.
Here is the start of the code for the penguin game this is the start where the user can tap the screen or click the mouse if the player isn’t dead or hasn’t tapped already the penguin would play his starting animation.
once the animation has played an “animation played” and a “has tapped” boolean are set to turn this stops the start animation playing again when someone taps, it is also needed for the next part.
when the “animation played” boolean has been set to turn this then allows the ability for the player to start “running” this will make the character run forwards without stopping. This is set to an event tick so it’s checking every tick or frame if the player is dead.
at the same time on the event tick, the health and scores are set this is done by casting to the endless runner character getting the set health, in this case, it was float set to 1 and adding a float <= float that works out if the health is below 0 if this is true the score will be saved by creating a save object casting to a save game blueprint and setting the score in the save game to the score the user got and then saving it to the score slot within the save game, the character would then be destroyed another boolean called “endgame” is then set to true and the end screen widget is opened.
by pressing A and D the character will move left and right but would not be able to turn more than 45 degrees so the character doesn’t start running backwards or into a wall this gives the player to turn 90 degrees at points in the game that would allow it but this also doesn’t let the user turn the character anywhere else. unfortunately, due to time I didn’t put any turning platforms in.
this is a small function within the endless runner blueprint this sets the time using an integer that is then set to the end time. the seconds is counted up in the player hub widget.
This is then the player getting damaged this plays an animation showing the penguin getting hurt then takes 0.333 health of the player health float then sets the animation back to the sliding.
This is another function that sets the coin total that is then used in the player hub widget that counts 1 point for each pickup.
this is the blueprint that is used for the pickups this calls the function from the endless runner blueprint plays a sound at the location and then destroys the pickup but only when the player character overlaps the pickup.
This is the blueprint for the blockers or the rubbish that is stopping the Penguin this much like the pickup calls a function from the endless runner which is the one that hurts the character then it destroys the blocker so the character can keep going.
for the floor tiles or platforms, i had to make a 3d model in Cinema 4D then made a particle system to make it snow and added in an attach point using a target< a trigger box placed at the end, blocker spawn points and a coin spawn area.
when the endless runner character reaches the end of the platform another platform would spawn in front of it, however, to make it look like it’s an endless road I made it so it shows 8 platforms at a time.
To spawn the coins onto the platform I had to make a function within the blueprint to do this i get a reference to the coin spawn box and got the size of the box and the locations within the box added them to set a random point within that box then added the coin actor.
for the blocker spawns, i made another function in the blueprint and got the references for the 3 spawn points and turns them into an array.
then to make them spawn I made another function where the new array is put into a random integer within a range from 0 to 3 and spawns a blocker actor in its place but will only spawn 1 at a time.
this is the blueprint used the endless runner game mode. in the event tick if the user has tapped at the start the game will start counting the seconds they have played for then if the game had ended it would remove the HUB widget from the view.
the begin play event is used to set the hud to the viewport and also uses an add floortile function.
in the add floor tile function, I cast to the endless runner to get the is dead boolean if its true the floor will stop spawning if it’s false it would spawn a random floor tile from the floor tile array setting the floor tile to the attach point.
for the end screen when the player had died the end screen will spawn this will then allow the user to input their name in an editable box, when the text has been inputted in the text box it creates a save game from the scores save casts it to the score saves loads a save slot called names sets the name to what is put in the box then saves it this is then used in the leaderboard.
for the main menu, there was meant to be a video that plays of the characters in a bar together, unfortunately, the Unreal engine doesn’t let videos to be used as textures so I had to do it through a media player blueprint and turn that into a variable in the level blueprint and set it to source play this worked fine in the editor but when packaged the video stopped working and I couldn’t work out how to get it to work once packaged to fix this problem I used a still image of the menu video as a sort off place holder.
if I was able to redo this project I would have done it so I was just focusing on the one game and made sure the rest of the group was up to date and organised so things were finished quickly instead of having to wait for them to be completed.
I would have liked more time to work on this project as due to the time I had I had to cut corners and skip parts that were as import to the final game.