GetStartedWithUnreal

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Table des matières

1 Setting character by default...........................................................................2


1.1 Spring Arm...............................................................................................2
1.2 Camera....................................................................................................2
1.3 Creating an input action for jumping.......................................................3
1.4 Creating an input action for moving around............................................3
1.5 Input Mapping Context (Enhanced Input System)...................................3
1.6 BP_MainCharacter...................................................................................4
1.7 Setting up keybindings for moving around:.............................................4
1.8 Setting the look around logic:..................................................................5
2 Setting up the real jump and moving features...............................................5
2.1 Jump........................................................................................................5
2.2 Look around.............................................................................................6
2.3 Moving around........................................................................................8
3 Animation....................................................................................................10
Character Movement

1 Setting character by default


By going to class defaults and then setting auto posses player to player 0, the
character set up is the player that will be spawn in the island when I hit the
button play.

1.1 Spring Arm


This allows the camera to be attached to it so I can have a fixed camera that
follow the spring arm wherever it goes.
1.2 Camera
I added the camera under the spring arm so it will become attached to it and
then set up the parameters shown in the right side.

2
1.3 Creating an input action for jumping
The only parameter important here is value type, it is set to digital because I
am either jumping or not so it’s like true or false.

1.4 Creating an input action for moving around


This is for moving around and the value type is of course axis 2D because I am
moving on a 2D axis.

1.5 Input Mapping Context (Enhanced Input System)


Allows us to define which keybind or mouse key will trigger the input action
that we just created.
Here I bind the spacebar to the input action for jumping.

3
1.6 BP_MainCharacter

1.7 Setting up keybindings for moving around:

4
1.8 Setting the look around logic:

2 Setting up the real jump and moving features


2.1 Jump
Jump is a build in function.

5
This feature located in class default allows the player to jump higher if I hold
spacebar for only 0.5s

2.2 Look around


With this code the player will move with the camera which is something that I
don’t like. That’s why we need to detach the player movement from the
camera.

6
First uncheck this

And then check this box (use pawn control rotation) under the selfie stick.

And then to complete the code we do this.


Invert X and Y are set to invert the axis.

7
2.3 Moving around
This function returns the direction where the player is looking.

This is the final function so that the player can move according to the camera
rotation.

8
I did this so that when the camera is facing parallel with the ground the player
won’t stop moving, the pitch need not to be connected.

Note:
Enabling this feature in the character movement lets the player face
automatically the direction in which the camera is moved.

Now this feature allows me to speed the rotation of the player according to the
camera movement.

9
3 Animation

Starting with the event graph, we get the velocity of the character, and we
store it into a variable called speed so we can call it later. After that, we create
a variable called InAir to check if the player is still in air or not.
In this section I connected the different state machines. In every state there is
the appropriate animation.

Loop animation under the running animation needs to be set to true for the
player to keep running whenever he faces a certain direction.

10
11

You might also like