Categories
Uncategorised

GD2 Blog: Week 24

Collaborative Project

As of the 4th of April, I’ve worked on implementing several parented actors into the game by building off the base projectiles and base pickups. Including some modifiable variables accessed within blueprints to allow for non-programmers to tweak and edit.

First off, I will go over a couple of new projectiles added into the game. As shown on the left is the base projectile, which includes all the default stats for the projectiles (See Figure 1).

The middle is a heavy projectile, which is a child object of the base projectile, it overrides the speed and size from the base projectile to make it much more slower and larger, it even does more damage.

The right has a smaller projectile, which is faster but does a lot less damage than a heavier projectile would.

Figure 1

The base projectile has a integer variable that is able to be set within the blueprint, this being the damage, this is declared within the Base Projectile and carries over to all its children (Figure 2).

Figure 2

Included in the header file of our base projectile are our default values. These are values that we’ll be able to access from the child classes of our projectile. Included is also several virtual voids that determine the projectile speed, size and damage (Figure 3).

Figure 3

We can also use a similar form of inheritance with virtual voids, these enable our child classes to override said functions and to implement their own logic.

“The majority of the inheritance work is by creating a base class that our children can derive from which contains the primary logic that all children are always expected to perform.”

Wojtek, 2021

Another actor within the game I created is a pickup base which utilizes this, it contains a virtual void for an overlap event as well as variables determining the size of the pickup (See Figure 4).

Figure 4

Figure 5 shows what the function looks like within the base pickup, whilst keeping the variables we can override and change what this entire function does in our child actor – the base function contains a debug message and a simple cast to the player character.

Figure 5

In Figure 6, we change and override the function completely. This means that previous code within the function will be overridden with everything written in the child function – we replace the debug message with a different one and include a pointer to the player to add onto their health.

Figure 6

Figure 7 shows both pickups, the base one on the left and the health on the right.

Figure 7

Once overlapped, our different types of debug messages will display. However as we didn’t override the overlap ended function from our basepickup, our Health will keep that function as normal (See Figure 8).

Figure 8

Within our Base Projectile’s constructor, there is a projectile movement component in-which we define our base stats for the projectile’s behaviour (See Figure 9).

Figure 9

Included in some of the component definitions, we include our virtual variables in them, these return our set variables from the header file (See Figure 10).

Figure 10

As most of the projectile movement component is sorted out within our base projectile, we won’t need to reimplement most of the entire code for it again.

Instead we can just easily change what we need by changing the variables in the constructor code as well, which is what our virtual variables will return to the collision component definitions.

For example, we can change the variables in the heavy projectile’s constructor to have a higher size, slower speed and higher amount of damage (See Figure 11).

Figure 11

So far I have managed to set up a good base for creating any different projectiles or pickups off of if necessary, I’ve also managed to make a variable that is editable via blueprints.

However, if my current collaboration team asks for more variables to be editable, I could try and improve this system by making more of them blueprint editable such as the size and speed – this can enable for other people working on the game to easily change these without having to get into the code.

Bibliography

Jolly Monster Studio. 2021. Unreal Engine C++ Fundamentals – Using Inheritance by moving the player & particles along a spline. [online] Available at: http://jollymonsterstudio.com/2021/10/17/unreal-engine-c-fundamentals-using-inheritance-by-moving-the-player-particles-along-a-spline/ [Accessed 12 April 2022].

Leave a Reply

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