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

So on the 5th, I wrote about how I wanted to go see Generation Axe. I’d been thinking of going since before the tickets went on sale, and so I decided I couldn’t pass it up, got off my butt, and went. It was worth it. But between OT at work, and concerts, and trying to figure out day care for the little dude, it’s been almost a week since I’ve done any of the tutorials! Lucky for me, I still have both my computer, and my fingers, (and ears and eyes) so lets see how far I can get with this tonight.

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

Lecture 86: Managing Texture Tiling

Simple lesson. Only thing that’s done here is duplication of a material, assigning it to geometry, and then editing the texture coordinates in the material to be scaled appropriately based on the size of the box we’re placing it on. Realistically, any sort of geometry that I create in a 3D application would have appropriate UV’s assigned to it. But texture coordinates get scaled/panned all the time in VFX.

Lecture 87: Pointer Protection Process

It’s easy to get crashes if we follow a nullptr. It’s important to check pointers before use, and that we always initialize when declaring a pointer.

While it’s bad to follow a nullptr, it’s worse to follow nothing. At least we can check for a reference to a nullptr. So when declaring “ATriggerVolume* PressurePlate, we should make it = nullptr.

If we open a .h file, we can ctrl f to search for *. This will help us find our pointers, and we can ensure that they have been set to = nullptr.

Then, we can use if statements to print a meaningful error if our pointers = nullptr.

ie: if (!PhysicsHandle) { return; }

Of course, you need to actually compile your code before pressing play in UE 😉 By using if statements to return, and combining with UE_LOG() to output errors, we can “fail graciously”. We don’t crash, and hopefully we know why.

Keep in mind that when we replace the TriggerVolume pointer, that we must return TotalMass. If a method is expecting data to be returned, it’s not enough to simply “return”, you must return data.

Lecture 88: Exposing Events to Blueprint

Blueprints are nice! We can create events in our code which are then accessible from Blueprints using UPROPERTY(BlueprintAssignable)*

Timelines in Blueprint can allow more than just boolean type switches. ((Warning: If you can avoid timelines, you should. This is the lesson I’ve learned at work at least. Timelines aren’t bad if you only need to process one or two, but if the blueprint is being used many times in a level, timelines can get quite expensive.

By using:

UPROPERTY(BlueprintAssignable)
Type VariableName;

We can create an event that we can make use of in our blueprint to trigger the door opening.

Get in the habit of compiling in Unreal as the errors you will receive are far more useful.

You don’t “call” an event, you “broadcast” on an event.

We don’t want to rotate the door in the cpp file, rather we will want to broadcast an event so that we can rotate it in blueprint.

One thing to be aware of, is UE/VS don’t seem to work well together if you’ve left your files open for days at a time. I couldn’t get the autocomplete to work until I closed everything down and re-opened.

FRotator deals will pitch, yaw, roll
Set Actor Rotation deals with roll pitch yaw

Inconsistencies are fucked.