Mastering Unreal Engine 4.X
上QQ阅读APP看书,第一时间看更新

Building the blueprint

Now with everything done on the animation blueprint side, it is a very simple step to get it all together. First, hit Save on the animation blueprint and close it; we don't need it again.

You can now right-click inside the content browser, and choose to create a blueprint. This will open the classes list to choose a base class for this blueprint. The ones on the top are the most popular ones, but we want to create one based on our Gladiator C++ class we made at the beginning of this chapter. So, you can look at the bottom section and type the class name in the search box and you will find it. Use it and create the blueprint. Give it a name and remember this name, as we are going to use it in the final step of this chapter in order to use it as the default pawn.

Once you have the blueprint, double-click on it in order to open it, and don't panic because it doesn't look like what you expect, or does not look like a normal blueprint based on an actor.

What you are seeing is called the default view and it is displayed usually for blueprints based on C++ classes. You can see a note telling you that, so you can hit the Open Full Blueprint Editor button in this note in order to open the normal blueprint.

Don't be worried, the default view is still accessible but in a different way. While in the full blueprint editor, if you want the default of any of the components, you can just hit the Defaults button on the top bar and it will load the default for you in the right-hand panel.

Now you can see, and locate all the components we have created at the constructor of the Gladiator class, such as:

  • CameraBoom: Sprint Arm Component
  • FollowCamera: Camera Component
  • EffectSprite: Paper2D Sprite Component

You'll not only find these three components, even though those are the three components we've created through the C++ code, there will also be other components that are, always there, by default, within any blueprint based on a character class.

Now the last step in creating the player blueprint, is to assign some default values. As there are tons of default values for each of the components, you can go around them and tweak them to fit your needs. The most essential ones to give you a working character now are the assets.

Select the Mesh component from the components list, and open its default values by clicking on the defaults button on the top bar.

In the animations section you need to ask it to Use Animation Blueprint, and assign the animation blueprint we created earlier in this chapter.

Then select the Skeletal Mesh character you want to use from the free assets you have imported in to the project.

Now, you finally have a fully working character…But wait a second, there is still one more thing to make it perfect.

As you can see, the character mesh is not well aligned inside the capsule (the collision), so you probably need to select the mesh again and keep adjusting its rotation to face the correct direction of the capsule and adjust its vertical axis positioning, as it is flying on air now. A few tweaks, but it will make things a lot clearer.