Post Processing II

Post Process Vol 1

Get All Actors of Class and For loops

Here we are making a few updates to our game.

The first Blueprint is a collectable token. Every time Kristina gets one, her score is updated and then also it checks if she has all the tokens in the level. If she does a Boolean is switched to True and then she is able to use the portal to the next level.

Here in Kristina’s Character Blueprint we are getting all the tokens in the level so we can compare that number to how many tokens Kristina has collected. Also we are trying out a for loop by grabbing all the tokens and assigning each one a random material.

Lastly we are making a slight update to our portal blueprint that takes the character to another level. We are casting to Kristina to see if she has found all the tokens or not. If she has, the Blueprint works. If she hasn’t, the Blueprint doesn’t run any of its code and she can’t go to the next level.

Using Arrays

Arrays are a collection of variables of the same type. Say you had an array of integers called myArray. It could be 4,3,6,2,0,6,1,5. The array’s length would be 8. But be careful – Arrays start at 0. myArray[0] = 4. myArray[2]=6 and so on. In Unreal you can have arrays of anything from materials to actor blueprints to text.

Here is a very good tutorial on it if you need more info.

Today we’ll use arrays for two things. 1) We’ll give our Kristina character a random color at start up and 2) We’ll make a trigger that says random words of encouragement to Kristina. Everything is updated on the gitHub.

In the BeginPlay event in our character blueprint (Kristina) I made an array of three materials and then set the material to choose  a random one from my array.

 

Next to make my random talker widget I made a RandomThingToSay array, wrote three things in there and then on the Construct event set a CurrentThingToSay text variable to take a random slot from the array.

Then I bound the text in the widget to the CurrentThingToSay variable.

In the actor blueprint I set up a box collision to add and remove the widget to the screen.

Using Cinematics

We are going to first make a Level Sequence. Click the Cinematics button above the viewport to do this. Then name your Level Sequence and pick where it will go.

I also made a CameraActor and added it to the level.

In the LevelSequence I then added my CameraActor so I could animate it.

I added a Transform and animated the camera panning through my level. I also added a Camera Cuts track. This will take over from the regular player camera for the duration of the Sequence. I also shortened my sequence to 60 frames (2 seconds) by moving the red scrub bar to the left until it was at frame 60.

The event I’m using to trigger my camera animation is just BeginPlay. I start by fading in the level, then I grab a reference to the introSequence, get the Sequence Player and then play it. Later I add my UI widgets to the level. You can trigger a sequence with anything. The trick is to find a reference to it. If you are triggering it from an actor blueprint in your level you can use “Get all Actors of Class” node.

Making an intro/pause menu

First we make the widget. You can see below how I have everything organized. I put all the buttons in a Horizontal Box and called it “pauseMenuStuff” and then I put the info that comes up when you click the “INFO” button in a Vertical Box and called it “informationSection.” I then hid it so I could see my regular menu. I also made “pauseMenuStuff” and “informationSection” variables by ticking the Is Variable option on the upper right corner.

Next I setup my button events. At first I hid the info section. When you click play, the game unpauses, when you click info, the 3 buttons and game title go away and reveal an information section with a button to go back. When that button is pressed it hides the info section and puts the 3 buttons visibility back.

Lastly we need to toggle this menu. First I went into my project settings and made an InputAction called “pause.” I recommend making this the Tab key while you are testing as escape will quit the viewport. Very important! When you select the “pause” action be sure to tick Execute when Paused so that you can toggle out of the menu by also hitting the pause action. The logic below is removing the menu if it’s already showing and adding it if it isn’t whenever I hit the pause key. I put this in my character blueprint.

Open Level

From class – we added a variable to the Actor blueprint to set the level, then we passed it to the game instance so that in the loading screen level we called up the current level variable in the game instance and loaded that. That way you can use the loading screen to go to any level.

Game artist for today – Pamela Reed + Matthew Rader

SOUND

GNOG – May 2017 – PS4

 

Sound in Unreal is either a wave or a Cue. A Cue enables us to do a little programming on the sound. Below I made a jump cue and it randomly selects one of three jump noises so you don’t hear the same sound repeated again and again.

 

You can then pull up the sound through code anyway you’d like. Here I’m triggering it every time I hit the jump key.

Video Games as Art

Lecture from 5/2/2017

Moving Platform

This is an actor blueprint. In the Viewport I just added a simple cube and scaled it down on the z-axis. Here I have several variables. Notice the floats “Speed” and “How high” are exposed. I clicked on the eye icon on the right. This enables you to set the speed on a per object basis. So every time you drop a platform in a level you can make it move to different heights and at different speeds. goingDown boolean is left at false. The other variables are set at BeginPlay based on where the platform is located.