Research Coding Projects 3D

Stealth

Video

Description

A platform game I created using the new engine of Epic Games. (a.k.a. Unreal Engine 4).
I liked the game "Stealth" that was created inside Unity3D and recreated the a similar game inside Unreal Engine 4.
I re-used all the meshes from the original game to get the same feeling as in the original game. It was the first time I used Unreal Engine 4 and I was supprised how easy things progress when using the blueprints ( Node-Based Coding ).
All scripting is done by myself, also all the levels are designed by me.

Engine

  • Unreal Engine 4

Language

  • Blueprints

Screenschots

image carousel

Some Details

Level Streaming

I used Unreal 4 for the first time creating this project. I was supprised how easy the blueprinting in unreal 4 worked.
I worked before with a node based coding environment in, so I already knew what I could expect from blueprints but this was above my imagination.
As you might have seen my game contains multiple levels.
In other words I needed a way to load diffrent levels at runtime.
A way to do this in Unreal 4 is by levelstreaming, when the players enters an elevator the screen turns black the previous level is unloaded and the next level is loaded.
When the next level is loaded the screen fades back in so the player does not see the trasition between two levels.
 
   
As you can see, an event is triggerd when the player overlaps with a trigger zone.
When he does, all the input is disabled and cinematic mode is started, this allows me to start the matinee to fade out the screen.
When the screen is black an other event is triggered that the loading of the next level can start.
You can see this in the second image, there is a flow arrow going from "CameraMatineeActor_LoadLevel01 -> LoadLevel" to "Load Streaming Level".
When the level is loaded the previous level that was completed is unloaded from the game.
At last the matinee will finish and the game will be visible again for the player also the players input is re-enabled again.

Enemy Movement

Enemy Patrol

Because I used level streaming I had some issues using enemy pathfinding.
Normally Unreal 4 uses a "NavMesh" to calulate where an object can walk, but because I used an early version of Unreal 4 levelstreamed "NavMeshes" where not possible yet.
There where only 2 solutions to this problem:
  • Undo the levelstreaming I just created.
  • Create my own pathfinding.
I choose the second option, I'd like to point out that things might get a bit unclear because it's a huge blueprint I had to create to make the pathfinding work.
I thought of an algorithm to make the enemy move around the level.
I recreated the pathnode system of UDK inside Unreal 4 to make my enemy move around.
Every pathnode has knowledge of every other pathnode at the start of the game.
A ray is casted from every pathnode to all the other pathnodes,
if there is no intersection with the any object the pathnode is added to a list that I called connections.
To give a visual presentation I added some screen shots.

 

You can see how the pathnodes are connected with each other and if the pathnodes are connected this means there is a way that the enemy can travel there.
Ofcourse I'm not taking into account that the pathnode can be on a diffrent height, because my game does not have any difference in height it's not necessary here.
Next thing I did was making the enemy patrol over certain pathnodes.
This was the easy part of the enemy behaviour.
The next screenshots will explain how I did it.
First I check if the actor is close enough to the next patrol point to go to the waiting state.

 

Then I made a framedelay to let the actor wait a moment at his current position.

 

When he's done waiting we prepare him to move to the next node.
When he reaches the end of his patrol, we use a modulo operator to let him move to the first patrol point in his list of patrol points.

 

Enemy pathfinding

Now that we can move our actor over a path it's time for the real challange.
I came up with the following solution.
When the game is in alarm state the actor needs to get the connections of the node is positioned at.
Then he needs to go over all the connections of that node and move to the one that is closest to the player.
When he reaches that node he'll do these steps over and over untill he can see the player.
If the player is visible to the enemy then he will move to the player when the player moves out of his line of sight he will proceed following the path that leads to the player.
Like I already said it's a big blueprint but will go over it step by step.
First we need to check if the alarm state is enabled like this:
 


If the alarm state is enabled three thing will be checked.
  • Is player in range
  • Is player visible
  • Calculating the distance to the player
First w'll check if the player is in range.
 

If the player is in range the enemy will start shooting at the player, until he dies.
If the player is not in range the enemy will check if he is positioned at a node.
If the the enemy is not positioned at a node he will find the closest node to himself,
also he will check if that node is also the closest to the player.
 

 

If the enemy is finally positioned at the node he will cast a ray from his location to the players location,
this is done inside the method "Hitted Environment" if this method returns false the enemy will towards the player.
If this method return true he will find the closest node again untill he finally can see the player.
 

 

Next thing that the enemy will check is if he can see the player.
 


In the method "CanSeePlayer" he will check if the player is visible.
If this is not the case a delay will be fired this will count down untill zero.
When the count down hits zero the alarmstate is disabled and the enemy returns back to his patrol state.
 

Last thing that will be check is the distance to the player.
this check is to see if the player is in range so that the enemy is able to shoot on the player.
 

That's it for the basic of my pathfinding.
If you still have questions you can find my contact information here.