2/13


Start your day with a warm-up


https://80.lv/articles/less-than-10-of-games-released-on-steam-in-2024-were-made-with-proprierary-engines/




What are you learning?

Weapon System, changing animations, importing meshes.


Why is it important?

This is the start of everything. We are building a game so it is important that you follow along. If you start going on your own and fall behind, it is unfair to stop the class because you chose to do your own thing. If you are confident that you know what you are doing, I have no issues with you moving on your own but you will be held accountable for the project.

How do you show that you understand? What is the assignment?

Follow along and build the game.


Download and install 

https://www.fab.com/listings/98ff449d-79db-4f54-9303-75486c4fb9d9

https://sketchfab.com/3d-models/shotgun-bec49e6f99e347cbb60e6390b2c4202c

We want the FBX Version of the gun



In the FAB, download the Animation Starter Pack

Launch Unreal Engine

Select third person

Scalable quality

Make sure starter content is checked 

Name it

Create

Exit out 

From your Unreal Games Launcher, select your unreal library

find and add the animation starter pack into your project

Find the game you just created and click add to project

If you get an incompatible message, select 5.2 version and it will work.

Open your game

Now you should be able to see a folder with all the animations that you added from the starter pack

We are going to add these animations to the project

In the animstarterpack folder, search for idle

right click Idle_Rifle_Hip

Hover over Retarget Animation Assets

select Duplicate and Retarget Animation Assets/Blueprints

Change the IK Retargeter to RTG_UE4Manny, UE5Manny

So what is happening is that it is converting the skeleton to use the updated UE Character

Click Retarget

We now have the new mannequin in the game

Create a new folder 

Place your animation in the folder

We will do the same thing with the Jog_Fwd_Rifle

and add it to the folder

We will do the same thing with the Fire_Shotgun_Ironsights

and add it to the folder

Open up the your folder with the new animations

Right click in the open space

Hover over Animation

Select Blend Space

Choose SK_Mannequin

Name it (I called mine ShotgunBlendSpace)

Open it by double clicking

The blend space transitions the different animations so it looks smooth during gameplay based on a value

Dock your Shotgun blend space

Open Horizontal Axis

The value for this blend space is Speed so change the name to Speed

We will update the character speed on the Maximum Axis Value to 500

The reason we are changing it to 500 is because when we open up our third person character blueprint, we can see that the max walk speed is 500

You need these numbers to match

Go back to the blend space that you created

In your Asset Browser search for Idle Rifle Hip

If your asset browser is not showing, click window and select asset browser

Drag it to the start of your animation

Do the same for jog and add it to the other end of the timeline

You should see a red line connecting the two points

Now if you hold control and scrub along the line connecting the idle and jog, you can see that it transitions from the idle to job, kind of like a tween

Open up your Shotgun Assets folder

Right click and select Animation Blueprint

Select SK_Mannequin (SK stands for skeleton)

Name it BP_Shotty or whatever you wish

Open up the blueprint

You will see that we are in the AnimGraph instead of the event graph but you can switch back and forth

In the Asset Browser find the ShotgunBlendSpace that you created

Drag it into the blueprint

We don't want to connect the  Blend Space to the Output Pose

If we did just this, we would NOT have our shotgun animation included

For this, we need to create a montage

Disconnect the two nodes

From the shotgun blend space output, pull out and select slot default slot 

Connect the output of the slot default slot to the input of the output pose

We are doing this so that we can play the shotgun animation later

Change the speed in your Shotgun blend space to 100 then compile

You can see the player is barely moving

Change it to 500 and compile

You can see it is moving way faster.

So what we want to do is make this Speed a variable so it changes depending on what we are doing

Right Click on the Speed Input of the node and select promote to variable

Switch to the event graph

Right click and add the node Event Blueprint Initialize Animation

So when the game starts, this starts as well

You want to send this information to the character that you are using so we are going to pull out from the output of Try Get Pawn Owner

Connect the output of your Event Blueprint Initialize Animation to the input of the Cast to BP_ThirdPersonCharacter

So we are sending the Animation into to the character

From the Character Output in Cast, pull out Get Character Movement

From the character movement node, pull out get velocity

The Get Velocity Node is different from the character movement node

It is a vector parameter (C++). A vector holds info for X,Y,Z which can be an axis or a location, rotation and scale)

Our Speed Variable is a Float

Se are going to want to convert it

From the velocity output, pull out vector length

So now it is sending the value of the velocity

Pull over your Speed Variable

Select Set Speed

Connect your Vector Length output to the Speed input

We DO NOT want to to connect the Cast to Third Person Output to the Set Node because it will only set it one time. We need it to continually update

instead, we want to connect the Event Blueprint Update Animation output to the Set Input

Disconnect the input of the Character Movement

When we cast info, it uses the computer performance more than just grabbing a variable

For this reason, we are going to create a variable by right clicking on the output of the BP Third Person Character and selecting Promote to Variable

Name the variable   Character

At the start of the game, it is going to start the blueprint animation and cast to the character then set the character value to a variable 

Drag the Character variable and select Get Character

Connect the Character Variable to the Input of the character movement

So now we have the animation firing to cast the info to the character

The cast is converted to a variable

The variable info is then going to the character movement

Open our third person character blueprint

We will be accessing the character movement

Go to Viewport and select the character mesh (NOT THE COLLISION)

With the character mesh selected, change the animation (animation class) to your shotgun animation

You can see the mesh has changes

Compile and play

We are now using the shotgun animation

When the player is not moving, it uses the idle animation and then the player starts moving, it switches to the jog animation

Time to place the shotty!!!

Make sure your gun is downloaded and an FBX

Unzip the file

Create a folder on your desktop called shotgun

Add the source and textures folders to the shotgun folder

Drag your shotgun folder into your content browser

Open up advanced

Select combine meshes (if you don't do this, you will get all the parts instead of the whole)

Import All

Now we have the shotgun static mesh in the source folder

Drag the shotgun mesh from the source to the shotgun folder and select move here

Go to the Shotgun Folder and delete source so all you have is the gun and the textures

Open up the Shotgun static mesh

Notice there are no materials on it yet, it is just the model

Open up your textures folder, right click in the open area

Select Material

Name the Material M_Shotgun (M is for material)

Open up the Shotgun material

Grab all the textures from the Textures Folder in shotgun and drag them into the material graph

The end of each name of the texture corresponds with the nodes

Connect them to the correct inputs

Click Apply at  the top left,  save and close out the shotgun

Open up the Shotgun Static Mesh

Select your M_Shotgun Material

Now the textures should be applied to the gun

Save it

Open up your Third Person Character Blueprint Viewport

***With the mesh selected***

Click Add

Static Mesh

You want this mesh parented to your original mesh so that it goes where the character goes

Name the mesh Shotgun

Add the shotgun to the static mesh in the details panel

If we just move the shotgun and place it in the hands of the character, it will not look right when we  are moving

We need to add sockets to connect the weapon to the character

Open up your SK_Mannequin from your meshes folder

Content>Characters>Mannequins>Meshes

In the search at the top left, type hand and find the right hand (hand_r)

Name it ShotgunRightHand_Socket

Right click on the socket you just created and select Add Preview Asset

Find your shotgun

Move and rotate the gun so that it fits nicely in the players hand

We will Stop here for the day and continue in the next session.