Categories
Uncategorised

GD2 Blog: Week 28

Collaborative Project

As of the 2nd of May, I’ve worked on the player character more by implementing FindLookAtRotation into their code so that they’re able to aim and look towards the cursor. As well as starting on several actors used for levels such as doors and a spinning projectile spawner.

I’ve also guided some of the team onto what I currently need for my game build. In-which, I asked for some models to block out the level with and some widgets that declare the game’s main menu, the ability to pause and level opening and closing screens.

They have been able to provide some assets for the game such as models and several widgets. Figure 1, 2 and 3 show some early stage widgets made by Jerome. Including a menu, pause and end screen.

Figure 1
Figure 2
Figure 3

As well as new widgets, assets created by Jordan have also been imported into the game – although not textured yet, I plan to use these ones in level blockouts (See Figure 4).

Figure 4

As for what I’ve been working on, I’ve improved the current player character by making them turn towards the cursor in-game.

This was fairly simple as I had to only use “FindLookAtRotation” from the Kismet Math Library to assign an FRotator variable. I then set the actor’s relative location to rotate only the Yaw of the player, so that they could only rotate left and right (See Figure 4).

Figure 4

What this does is simply find a rotation for an object using a start position and then pointing it towards a targeted one – in this instance, the start position was the actor’s location, and the target for them to look at was the Trace Hit Result for underneath the mouse.

“Find a rotation for an object at Start location to point at Target location.”

(docs.unrealengine, 2022)

However, there was one issue using this. As the decal would rotate alongside the player and thus change it’s position from the intended space underneath the actual mouse cursor (See Figure 5).

Figure 5

To fix this, I had to set the rotation and location of the decal to absolute ones instead. What this does is set parts of a component to have their location, rotations and even scale to be relative to the game world rather than the parent.

“Set which parts of the relative transform should be relative to parent, and which should be relative to world”

(docs.unrealengine, 2022)

Figure 6 and 7 show the result of me setting enabling absolute location and rotations on the decal.

Figure 6
Figure 7

For the player, I’ve also implemented an ammo system for them. The player starts with a max amount of bullets, and has a boolean to determine whether they’re currently reloading or not (See Figure 8).

Figure 8

Within the code to fire projectiles, I modified it to only fire if the player has more than 0 bullets present.

In-game, the player will have the ability to fire a certain amount of bullets as fast as they want, once they fire the first bullet the game will set the reloading boolean to true and thus set a timer to trigger a function known as “ReloadAmmo()” that resets the player ammo count to their max ammo and then set reloading to false (See Figure 9).

Figure 9

In-game, this enables the player to fire their ammo out as fast as they can click, however they’ll have to wait out on the timer for their ammo to fully restock.

This may give a sense of strategy to the game in that firing slower at a lower pace allows you to consistently keep in stock with ammo, however for certain situations you may choose to fire very fast but have to wait (Figure 10).

Figure 10

Starting on the first level, I set out a plan for what I intend to do. Later on I’ll be able to fill this with some more assets. The first level will contain several rooms where the player must avoid some projectile shooters in order to reach two switches that’ll open the level exit (See Figure 11)

Figure 11

Figure 13 shows a room using a standard projectile shooter made from awhile ago, once the player enters the room, the projectile spawner will activate – however it will deactivate once they leave the room.

This room is just a projectile spawner shooting down a straight hallway that the player must get through without being hit, there are several pockets of cover the player can take to shield themselves from oncoming bullets – their timing to reach these must be adequate.

Figure 13

Within the header file of our camera trigger, I’ve included an actor reference that takes from projectile spawners. This is so that we can set up a trigger area to activate a certain projectile spawner (See Figure 14).

Figure 14

Within the CPP file of the camera trigger zone, the projectile spawner is referenced will have their “IsActive” bool set to either True or False depending on whether the player is currently in the trigger zone or not (See Figure 15).

Figure 15

The reason why I’ve done this is to keep off-screen projectiles from spawning and taking up a lot of possible space during gameplay: for optimization reasons, the player won’t be able to see these projectiles if they were not in their rooms so they are disabled until they enter.

As seen in Figure 16 is a new type of projectile spawner, it is a child of the projectile spawner blueprint and has a “RotationMovement” component that allows it to rotate constantly and fire bullets in a spiral-like pattern (See Figure 16).

Figure 16

This version of the projectile spawner also spawns the light projectiles and a much lower projectile spawn speed than the regular projectile spawner (See Figure 17).

Figure 17

As we’re now getting onto putting levels together, the team will be focusing on getting our first couple of levels for the game done. Although time constraints may prove to be an issue and we might not be able to fully finish our game before the 20th.

I plan on making sure the rest of the group will be working towards the game, as well as polishing and refining it as much as possible once finishing my current tasks – so far my goal is to add more mechanics and levels.

Bibliography

Docs.unrealengine.com. 2022. UKismetMathLibrary::FindLookAtRotation. [online] Available at: https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/Kismet/UKismetMathLibrary/FindLookAtRotation/ [Accessed 10 May 2022].

Docs.unrealengine.com. 2022. USceneComponent::SetAbsolute. [online] Available at: https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/Components/USceneComponent/SetAbsolute/ [Accessed 12 May 2022].

Leave a Reply

Your email address will not be published. Required fields are marked *