TIL: Learn to Code in C++ by Developing Your First Game (Section 3, Lectures 66-70)

Udemy’s interface had just been changed, but I think it’s been sorted now… so the numbering back on track again. In this collection, we simply set up volumes to prevent escape of the room, make a trigger that closes the door after x amount of time, and then set up the basics needed so that we have a DefaultPawn character of our choice being used when we start a game.

Section: 3 – Building Escape – Your First Unreal / C++ Game

Lecture 66: Using Collision Volumes

A trigger volume simply triggers code, but a collider actually has physics attached to it. This way we can prevent people from passing through a door.
-Nothing really of note in this lesson.

Lecture 67: Using GetTimeSeconds()

– GetWorld()->GetTimeSeconds()

There are a couple of things going on right now that I’m not a fan of. One… our character is able to fly. I’d much rather see that the character is locked to the ground with gravity…. but I can live with it for now. The other problem is that our if statements are happening every frame forever. There’s got to be a more efficient way than that. I don’t like the idea of having to calculate whether things are happening at all times as that seems like a way to create slow-down.

Otherwise the new connection to GetTimeSeconds() appears to be the only new concept going on. The rest is shuffling around the code to make it a little more streamlined.

Lecture 68: Grabbing System Overview

We want to be able to pick an object up and move it. This video doesn’t actually discuss it… but hopefully when we get around to it, the system works more cleanly than what I had attempted to mess around with in blueprint last year. I had a few problems with how objects were constrained to avoid rotation, and the lighting also seems very weird on objects that are mobile.

The problems I see (since I prefer Zelda style moving to Skyrim style moving) with what Ben is doing is:

    1. The shadow remains on the wall when you move the chair.
    2. The chair lifts up into the air.

The solution that Ben wants to add shall include:

    1. Be able to lift the chair
    2. Use a component (Grabber.cpp) on the player
    3. The player is temporary which means adding a component is difficult
    4. The Game Mode sets the pawn
    5. Create a Default Pawn & GameMode blueprint
    6. Specify our modified Pawn

Any sort of presets such as starting inventory, lives, or time limits, or score to win the game should live int he GameMode.

Lecture 69: Modifying the Default Pawn Actor

Blueprint gets used in combination with C++ as it’s handy to have a template that you can connect to easily.

– With the game running, select the DefaultPaun, go to the Blueprints menu, and select “Convert Selected Actor to Blueprint Class…”
– We’ll give a name of “DefaultPawn_BP”
– Create a new c++ Actor Component called Grabber
– We then want to add the grabber component to the DefaultPawn_BP

Lecture 70: Inherit Game Mode Blueprint

– DefaultPawn_BP is an asset and it is ideal that we have the ability to rename it. This is part of the reason we use BP… is so that we can avoid hard coding our components.
– We need to get a BP version of our Game Mode.

The process is quite simple here… we simply find the GameMode in the C++ folders in UE4, create a blueprint from it, assign the default pawn, and then in our project settings, ensure that it is using the BP Game Mode.