OptoSigma Gate Ring I
Trailer
Collaborators:
Gavin Brogan | Gavin Dobson | Jacob Dumas | Thomas Hynes | Logan McCurdy | Sooryansh Sharma | Brendan Washnak
Background
While I was attending Purdue University. One of the final capstone projects that was completed was a mobile game for a company known as OptoSigma. This company reached out to me and the team that was formed to make a game.
We, as a team, met with them and drafted a contract. OptoSigma wanted us to make a simple mobile game that could be used for an advertisement. This game would be a simple hub world with at least two mini-games in it.
I made the two mini-games.
Game Play
Asteroid Game AKA
Gate Defense
Tetris-like Game AKA
Stack Assembly
Game Break Down
As stated, this game was made per a contract that my team and I made. The contract, in short, stated that the game needed to be a hub world as well as two mini-games.
As per our contract, two mini games were made by me and a little bit of few team members. Firstly is the Tetris-like game and the Asteroid game. Each game was programmed by me, and modeled a little by me.
Stack Assembly AKA
Tetris-Like Game
As stated previously, this is a Tetris-like game. So, that means that the final product is much like the hit Russian-made game Tetris. This is the first mini-game that I worked on.
I worked on the programming for the game as well as the modeling of the parts that fall. The only thing that I did not work on is the UI. That was done by another person from the team that was formed to fulfill the client’s requirements of the contract.
Inputs
Down
Even though I did not work on the UI. I still programmed the controls for the Tetris-like mini game. The above is the blueprint for the function that makes the block move down faster.
Many of the functions for input are simple. A UI element is pressed to simulate the keyboard command that is pressed. Then the function that I wrote is activated. The code is above. It is a simple function that speeds up the global time dilation. In other words, it speeds up the game. This causes the game to speed up and makes the block move faster. The blueprint is set up so that when the button is released. The speed goes back to normal. The final thing that the blueprint for the drop function is to play a sound.
Try Lateral Movement
This function is the actual movement for the blocks. This function is both the left and right movement. The only thing that needs to change is how much the block is moved.
First, add a world offset and use an input variable called Move Amount. The block is then moved based on the move variable set in the falling block actor. A for each loop with a break function is triggered to check for collision. A function is used to get any static meshes that the blocks have collided with. The box overlap actors are then called, and it checks if it is a world static. If the statement is true, it will stop the block from moving.
Left and right are two separate functions since they need to separate key binds. Firstly, the left and right may appear to be the same, but that is wrong. They have one little thing that makes it different and enables the block to move from left to right. The lateral movement function is then called to give the block the movement and static mesh checking. The variable is set during the key bind that is called based on the UI.
The other key bind that is used is R. The UI will simulate the R key being pressed, then the rotate function is called.
This rotate function starts by adding an actor’s local rotation, then it goes into a similar loop to check for collisions, so that if it detects the wall of the play area. If it does, then the block will not rotate. Hence why the ninety is added, and if it is true for a collision, then that ninety is removed.
Left
Right
Rotate Function
Rotate
Construction
One of the main functions of the block actor is the construction function. In short this function runs every time the block is spawned in the world or compiled.
Construction Function
This is the construction function. The construction functions call multiple smaller functions to make the different parts/shapes that appear in the mini game. This is the overall function: a switch is triggered first with a random integer. Then, the setting of the static meshes and finally the setting of the vectors for the blocks that make up each part.
Set Mesh Function
The set mesh function is straight forward. There are four different meshes that get set. The function image shows the first one, but the code is the same for all for. A set mesh then a add local offset to set the position of the mesh.
This function is used multiple times through the construction script so that each part/block is made. The only thing that changes is the local offset for each static mesh.
Drop Function
The main functions of the game are the drop function and the line erase function. This area is for the drop function.
The event that begins to play is the first function that gets called after the construction function is called. The event begins to play a function, enabling the input of the keyboard (including the UI that simulates it). A timer is then triggered to begin the downward movement.
Event Begin Play
Line Trace Loop
At the start of the drop function getting called a line trace is called. A variable is set then a for each loop begins. This loop is a line trace to the bottom of the play area.
The next lines of code that are triggered are the check if it can drop/clear the timer and the block falling.
The check if it can drop is a simple branch with a do once to set the variable to false and then clear the timer. The block falling is a branch and an add actor world offset. These two nodes of code check if it can be dropped, then if it can then the block will be moved downward on the Z axis.
Check If It Can Drop / Clear Timer
Block Falling
Spawn Single Block Actor
The for each loop is the first thing that gets triggered when the block is unable to fall any more. The block will stop and a single block actor gets spawned. The spawn location are the mesh components that collide with the bottom of the play area. Then something strange happens next. The next line of code deals with line deletion and the spawning of new blocks.
Spawn Falling Block
Before I explain the check lines function, this code will be explained. The spawn falling block is set at the pre-determined variable, and the global time dilation is set to one, then the fallen actor is destroyed. After this line of code is completed, no more is triggered. This is the loop for the falling blocks.
Check Lines
In this actor, the line deletion as well as the calculation of the score is done. All of which is done in a single frame when the block touches the bottom of the play area.
Check Line
There is a score function that gets triggered first, but the more important is the code that is in the check lines function. The first of which checks if the line is complete. This is done simply. The code gets every actor that overlaps with a collision block. Then checks if it is at least ten blocks wide. If it is, it will move the blocks down and then clear the line.
Destroy Actor
As I previously stated, two more functions get triggered after the check. Firstly is the destruction of the line.. This is done similarly to the spawning of the single block; however, it does not spawn a new block. Instead, it deletes them based on an array that a loop checks for. This array is the completed line.
The other function of moving the line down is also not that complicated. The code will get all actors of the single block. Then, from that, the for each loop is triggered using it as an array. Next, a branch is triggered to check how much the blocks need to move down. True will make the blocks move down.
Move Line Down
Score
The score UI is not made or coded by me. Instead, I made the function that detects how many blocks are placed and the code for the line. In short, when a block falls ten gets added to the score and hundred will get added when a line clears.
Firstly, the coding for the loop is not as complicated for this game compared to the last. The reasoning for this is that the game itself is not even all that complicated. A gun shoots when the user presses the screen. If the projectile collides with the asteroids. This is a simple gameplay loop. This is also the same loop that the client originally had in their game. I was in charge of converting this loop to the Unreal Engine 5 format.
The first thing that gets triggered is a line trace. This line trace detects any static meshes that are under where the player clicks/touches. The line trace will then break the hit and use the location of the hit as a variable to have the gun look at where the click is. The gun will then rotate in the direction of the placement of said click. The next thing that will happen is the spawning of the laser. The laser is a projectile.
Asteroids
The next actor that is of importance is the asteroids themselves. Firstly, the asteroids are a homing projectile. This means that the function of the begin play. The begin play begins by casting to the gun actor. This actor will then be set as the homing actor component.
In the check lines function, has three functions that are triggered. The first of which is the add ten. This function is a simple addition to a variable. There is a setting of points variabel for the UI. The same is for the level. However, it is calculated a little differently.
The level is added after a counter checks ten lines cleared. This will cause the level to be changed.
The addition of hundred is triggered after a line is cleared.
Event Tick
Add 100
Add 10
Single Block
Event Begin Play
The single block actor is the block that is spawned after the part / block collides with the bottom of the play space. The single block will be placed in the same spot that the original part. The begin play will get that location variable of the Z based on the original part.
The event tick will set the actor location based on the Z axis variable. If a Z variable is not true the actor location is set.
Gate Defense AKA
Asteroid Game
So, the first mini game that I made for the game was the Tetris-like game, but the other was the Gate Defense game, aka the asteroid shooter game.
This game was originally a concept that was proposed to me and my team when I was working on the project for our client. The client had a very early version of this shooter game already. However, it was not made in Unreal Engine 5. This mini game that I made took the gameplay loop that the client originally had and changed it to fit the Unreal Engine 5 format.
Gun
Add Level
Shoot Gun
As the asteroids are spawned into the scene. I previously stated that they will start heading towards the player. The above code is the homing code; however, how does it get destroyed? The code below is the collision checker.
When the asteroid collides with the laser, a series of nodes will be activated. First, both the asteroid and the laser are destroyed. After these nodes are triggered. The next nodes are the setting of the asteroid’s score, then an explosion is emitted in the location of the asteroid that was destroyed.
Begin Play
Asteroid Belt
Around the player is a ring of asteroids. This is an in-engine system known as Niagara. The Niagara system is an effects system that Unreal has implemented into it. I made the ring with the particles being the asteroids. The asteroids collide with a static mesh that is out of sight. This mesh will use the particle data to get the positions of the asteroids. That will then be used to get the spawn location. That is then used in the function shoot at player.
Collision Checker
Set Object by String
After the function is triggered to set the location for the shoot at the player event. This event is a simple setting of a variable. Then that is added to a new vector variable with Y being 9000 and a random float for Y. This new variable is then plugged into the spawn node for the asteroids. This asteroid spawn is where the particle asteroid is spawned.
After it is spawned, a series of events of checks that check how many asteroids are spawned. After these checks are true. The game will continually get harder and harder. Until the game is three times the normal speed.
Get Particle Data
Spawning and Checks
Setting of Variable
Glass
The final thing that I programmed for the asteroid mini game is known as the Glass. This glass is a collision block that will remove the asteroids that collide with it. The glass acts as a loose condition for the player. Once five asteroids collide with it the player will lose the game. This is done by a simple subtraction of an integer and a branch with a check that checks for a value of zero.
Glass Lose Condition
Lessoned Learned
There were many things learned from this project. The first of which was how to work for a client within the constraints of a contract. I stated that I formed a team and we, along with the client, drafted a contract. This contract helped make things harder for us, but also easier. We had a minimum of what we needed to deliver, and if we tried to branch out, this constraint. We needed to contact our client. This was something that I learned from this project.
The second thing is how to make small mini-games versus a larger game. This may be something that is usually not a lesson, but to me, it was. This was because I was used to working on a single game for a period of time. These two mini-games made things tricky with my level of experience. But it was a valuable lesson to learn how to make something that is smaller in scope in an even shorter period of time.