top of page
Player rotation control

Let us now put the necessary software to make the character rotate in the opposite direction in the event of movement to the left (pressing the A button), and to do that, we must return to the point (MovingRightLeft) and make some adjustments

image.png

1- We have to create a variable (variable) and name it (moveright)

image.png
image.png

That variable is of type boolean, it gives only two values, either true or false, we created it in order to save the value that will make the character go right in the program, and this enables us to call this variable whenever we want to. 

2- We have to create a greater point (greater) than 0 

image.png

If the input value is  MovingRightLeft is greater than zero it means it will move to the right and if it is less than zero it means it will move to the left 

3- We have to create a point (branch) 

image.png

branch is one of the conditions of the condition i.e. it returns either true or false value 

4- We now have to withdraw the variable that we created a while ago, which is called (moveright)

image.png

When we drag the variable, we must click on (set), because we want to know the variable and save it

image.png
image.png

The value of moveright is now saved if the value of the entry (MovingRightLeft) is greater than 0 and the condition is true and all of that is saved in the variable (moveright)

5- We have to create a point (less) less than 0

image.png

If the input value is  MovingRightLeft is less than zero, it will move to the left 

6- We have to create another branch point, exit from the first branch, and put the moveright variable again

image_edited. jpg

The value of moveright is now preserved so that if the value of the input (MovingRightLeft) is less than 0 and the condition is false, the character will not go right, but will go left

image.png

7- We connect them all at the point add movement input so that the character can move

After defining the moveright variable and creating the software needed to make the character move left and right if the conditions are met, now we are ready to put the software needed to make the character rotate in the opposite direction if he moves left

1- We have to withdraw the character movement from the component list

image.png

2-We get a speed  Character movement by typing in the search box (get velocity)

image.png

We only want to make the character move left or right, that is, in the X axis only

3- Therefore, we have to click the left mouse button on velocity and then press split struct pin so that we can divide the character's speed on all axes

image.png

4- Write in the search box compare float

image.png

The compare float compares the velocity values with the value zero

5- Get the point (get controller) 

6- Get the point is valid to make sure that the control is correct

image.png

7- We extract from (get controller) the point (set control rotation) Let's set the character's spin level if the speed value is greater than 0

image.png

8- We extract from within the point (set control rotation) in the (new rotation) a new point with a name
(make rotator)  

image.png

After we define the new axis, if the speed value is greater than 0, then all axes in the make rotator must be equal to 0, and the reason for this is because: the level of rotation will not change if going to the right, as in the picture

image.png

9- Copy everything related to the rotation and link it to compare float if the number is less than 0

image.png
image.png

10- We make the rotation axis Z if the speed value is less than zero (180 degrees).

image.png

11- We call the moveright variable again and associate it with branch if the speed of the variable is 0 and if it is true then it will go to the right and if it is false it will go to the left, it becomes as in the picture

image.png

12- We associate everything we did with an event tick so that all those programs get when the game starts.

image.png

13- We will face a problem, which is that the character will always start facing the left side, and to solve it, we have to make the moveright variable always work at the beginning of the game by pressing it and making the value always active

image_edited.jpg

13- Go to the spring arm option and set the rotation level from relative to world

image.png
image.png

The reason we put the axis of movement to the world is because at the point (add movement input) the movement is affected by the world and not by the character

image_edited.jpg

I hope the explanation is clear and thank you for your kind reading

bottom of page