UE4 blueprint learning chapter (8) -- basic movement of characters

In the C++ learning article, we introduced how to use UE4C++ to handle the basic movement of the character, so this article introduces the use of blueprints to handle the basic movement of the character.

1. Create the Character class;

Add a SpringArmComponent component, and add a CameraComponent component below it to see the character. The SpringArmComponent is added to handle more smoothly when there is an occlusion between the character and the scene.

 

2. Process input, axis binding and key binding in project configuration;

What are axis bindings and key bindings?

Axis binding: It can be considered as continuous input and will report its own value frame by frame, even when no movement is performed, such as the joystick on the handle and the mouse sliding in the X and Y directions. It usually handles the character's walking and up, down, left, and right views, etc. .

 

Key binding: Bind a key to handle events when the key is pressed or released, such as shooting, jumping, etc.

 In handling the movement of the character, I handle the movement of the character, looking around, jumping, crouching, shooting, opening the camera and other operations.

 move:

 There are two ways to move the character. One is that the character can face the direction when the character moves, and the other is to use a controller (PC is the mouse X, and the Y-axis slides to change the direction the character is facing). The parameters that need to be processed are:

In SpringArm, use Pawn to control rotation and the Pitch, Yaw, and Roll inherited below are all checked by default.  

The decisive parameters for the above two methods are:

For example, when we start a shooting game without holding a gun and the character always faces the direction of movement, we set UseControllerRotationYaw to false and OrientRotationToMovement to true;

Later, after we got the gun, we kept pointing in the aiming direction. At this time, we set UseControllerRotationYaw to true and OrientRotationToMovement to false;

Look around:

 jump:

 Squat down:

 Opening:

Among them, crouching, jumping, opening the camera, etc. all add a bool value as the character status value of the animation blueprint to handle what animation the character should play in different states.

The processing of opening the mirror is just to lengthen or shorten it by processing SpringArm's TargetArmLength.

Guess you like

Origin blog.csdn.net/qq_42597694/article/details/130427770