My realistic First-Person character overview

Hello forum.
So after a few days of struggling I’ve finally managed to modify the TPS sample blueprint enough to fit it for an realistic first person character.
By realistic I mean a character in which the player would feel like in a normal human body.

I’m putting this here for two reasons: If you’re trying to get the same effect, feel free to use some elements here for reference. If I get requests, I can make a video tutorial on setting the thing up. Second reason is for myself. Since I’m not extremely experienced in ue4 (working in it for 2 months) I know there might be some errors here. If you have a better idea for some blueprints, let me know.

Also note: This is NOT 1000% done. Some tiny details have been left behind. Reason for that is the fact that this character is made for my project. I’ve got it to this level to ensure good gameplay. Also for one of them…not gonna lie, I just couldn’t figure out how to handle. I’ll mark the “to do” things at the bottom, and will be updating this post with every bigger change.

Here’s a video to demonstrate:

The changes shown here include:

  • Forbidding actor orient to vector on walk backwards;
  • Setting a special animation to walk backwards;
  • Linking the head and neck bones to the controllers pitch and yaw to make the head follow where you’re looking;
  • Limiting the head turn angle when standing still (so you wouldn’t break your neck).

Camera Position

One of the first and the most obvious things to do was to properly align the camera to the head. It wasn’t a hard thing to do, but required some thinking. First of all, the camera should sit on a position where it wouldn’t see inside the body, no matter the angle or animation. To get that I’ve set it a tad above the head itself. Realizing I still need the camera boom, I’ve shortened it to keep it from coliding and attached it to a socked I placed on the head. The attach wasn’t required, but I did it so the camera would have the same transition animations as the head does, thus look more classy.

Walking Backwards

A. Forbidding Turning Around.

Now stopping that son of a gun from rotating 180 whenever I pressed the go back key was a real jam, especially for a junior IT student, fresh with UE4.
I started from the event graph where placed a branch to determine if the player has decided to move backwards. As the condition I’ve set the Input’s Axis Value being bigger or equal 0.

Now the Axis Value of the turn would go below 0, that means the player just punched the keys responsible for the player to go straight back. What this does is sets 0 to a custom Walking Forward variable (explained later), switches from orienting the rotation to movement to using the controller rot yaw. Thanks to this, when the back key is pressed, the player would not turn around, and its rotation would fit the yaw of the controller (left-right movement).

If the Axis Value is above zero the script basically returns it to the default state.

B. Walk Backwards Animation

Now that the character was politely staying in rotation I needed to do something with the animation to make sense if while going back, the player would look down.
For that I duplicated both the walk and run animations, and changed their rate to -1

After that I made a new blend space, where instead of the popular 0-375 axis range, I went with (-375)-375 (I’m a rebel). Easy to figure out what happened next. The -1 animations went on the minus sides proportionally to the ones on the plus side.

With that behind me I quickly set the blend space as current for the actor, and went on with a script, telling when to use the negative animations, and how much.
In the animation blueprint for the character I’ve found the spot where the value of Speed gets assigned from some vector stuff.
Here the Walking Forward boolean was born. I’ve set the branch before the set speed working on the Walking Forward bool as its condition. If the character is NOT walking forward (bool = FALSE) the value assigned to Speed would be the opposite *(-1)] to the vector length.

So now. If the Inputs Axis Value is smaller than 0, the value of Walking Forward would automatically change to 0, which results in assigning an *-1 value to speed. Thanks to this the player neatly walks back, when he’s moving backwards.

Head Rotation

Since I’ve always been a detail freak, it caught me straight at the beginning that if the head of the character’s head wouldn’t move with the camera it would look really stupid. Even if I didn’t have any mirrors in my game it still would seem odd looking at your shadow and realizing that the head is static.
Now here comes the real crazy!

So I’m gonna be honest with you. When I got my self to finally fix this I’ve no **** clue on how to do it. Took about 3 hours of research to get any basic idea on what should I look into.
I’ve found some neat info on transforming the individual bones in the anim graph and that I could even rotate them by a custom rotator.
That was the stuff…only incredibly hard to figure out somehow.

I started from writing a basic script in the animations event graph that would give the rotation of the control rotation to a custom rotator named Head Rotation. Then I’ve set a basic Transform (Modify) Bone for the head bone in the anim graph. The efect was ok…sorta…pretty much no. The head did move with the mouse, but kept getting messed up when I moved the body.
Took me 2 hours to figure out why. Tried milions of different ways, and ended with nothing. Then I recalled the words of my high-schools math teacher:

So, not really knowing what delta rotation does in practice I tried it with the Actor and Control Rotation…And it bloody worked!
It did take a few more edits, here and there, but I ended up with a nice, neat working script.

Now for some reason the axis had to be switched but the effect was ok. I also slowed down moving the head sideways for nice purposes.
If you look closely, you can see that now there are two custom rotators: one for the head, and one for the neck. The reason is cosmetic.
After a bit of playing around I’ve realized that having the turning sideways done by the neck, and turning up/down by the head just looks better.

The Anim Graph was simple to set up.

As you can see, I have two separate modifiers with two different rotators.
Both use the same settings:

  • Everything disabled, but the rotation.
  • BMM Additive
  • Parent Bone Space

Can’t remember 100% if using other options works, and at this point I’m afraid to try, but quite sure only those give the good results.

Anymemes, after about 5 hours of yelling at my computer I have finally made a ready, neatly working script which turns the head wherever the player is looking at.

Limit Head Turn Angle

The final thing I wanted to take care off is the fact that when standing still, the player could turn his head 360 degrees around his body. Easy to figure its quite unnatural for humans, even if my character would be a robot in his (not so) bright future, I had to take care of that.

Using again lots of print strings I’ve found a nice degree (that’s how you call it?) between which I’d like the player to be able to turn his head.
In order to make the rotation of the head have its zero in the middle angle of the body I again had to use a** delta** from the actor and controller rotation. When I had that, I’ve set up a few logic rules.

So what we see in the first part is branch #1 with a condition. This branch is true only if the delta Yaw is a value between -120 and 100. If this is true the branch sends you directly to the Add Controller Yaw Input.

If the branch is false tho, it’s getting a bit more complicated, since without any additional elements on FALSE, the camera would simply stop moving. So I needed something to take care of this problem.
First of all I had to find out where the camera is stuck blocked at: right side, or the left side. For that I made a branch #2 which is true if the yaw is bigger than zero (looking left), and false if smaller than zero (looking right). Having this information now I had to tell the engine that if, lets say the head is blocked on the left side, and the player moves the mouse to the right than it’s fine, you know, let him move the head bro, and vice-versa.
For that I used two branches (#3 and #4) which as condition take not the delta, but the input axis itself. Now if the axis wants to rotate the head the opposite direction the head went before it was blocked, than the movement would be allowed.

I’ve also set up a small limiter on the pitch, to stop the player from looking all the way down.
So basically a nice little limiter. I can bet a lot of money that there’s a much easier way to do it, but if works for me, so meh.

I won’t show setting up sprinting here, because it’s really easy, I mean c’mon.

To Do List

As I mentioned, the player still has few things that I need to do with it.
Fortunately I think I’ve covered the most pain in the butt elements, and the rest won’t be so hard.

For now I’m happy with the player model, especially since for most things I needed, tutorials were barely findable, and answerhubs rarely could help the problems I had on the way.

The number one thing I need to take care of is to stop the player from turning his body around the wrong direction sometimes, when the camer would look to the right, and I’d decide to turn him around to make the body face it. For now tho I have no idea on how to make it, so if you have a vision about this, please let me know.
I’ll also have to fix the clipping at some degrees, but that’s a cosmetic.

Now I gotta work on some level design for my big project (the character is a part of it), and afterwards I might get to fully fixing the details on him.

Thinking of starting a devlog here on it. Might be fun.

But anyways, thanks for reading. Hope it helped and sorry for my English.
Have any questions/tips leave them here.

(5 hours of writing…well, ****)

Hey man, thanks for sharing. Great stuff! I have been avoiding the “stop character from rotating when I hit the back key” on my to-do list for weeks.

Fp cutscene

Glad I could help.
Also adding one more thing here:


If you want your character to play cool cutscene animation…or any additional animations, you have to do some weird things. Matinee might be great for normal cutscenes, flying cameras etc, but if we’re going to do something, we’re gonna do it right. If a fp animation would look realistic, the camera MUST move the same way the head does…and that’s not so possible with matinee. I mean, you can animate it in there but…why?

So to get it done you have to simply implement the animation into the characters animation script.
Then to play it, you’ll need a variable that will tell the graph to play your silly animation, or to do other stuff.
For this I’ve created an int variable. I’ve chosen to have 0 as default state (no cutscenes) and all the other numbers, to fit specific cutscenes the player would play.

Thanks to this we can nicely put a trigger in out level, and just make it change the variable to 1 when we want the anim to play, and 0 to make it staph.

The reason for the rotator there is that the one pro and con of this method, at the same time, is the fact that the animation would play from the rotation the player stands in, when walking into the trigger.
Thanks to that Set Control Rotation we can nicely set how the player will be rotated right before the animation. The delay there is important. Srsly.

Having that done and playing the animation we see one thing:

The reason for that is simple. When the animation plays, the camera is still the controller of the heads rotation.

The way to get over it is really simple tho (and took me 7 hours to figure out…).
All you have to do is…create a second camera, link it to the head, and disable auto-activate, silly.

After that you can put the info into the actor script like that:

As you can see, all the script does is activate and deactivate the right cameras(which is nothing compared to my stupid previous methood) . It also sets a few values. Those determine if the player can move and look around (also jump).

If you managed to neatly put all that together you should end up with a neat fp character playing cutscene animations. Cool, huh?

ps. This way of implementing animations is actually quite good for npc cutscenes that return to being regular npc when the cutscene ends.

Suck it, Matinee!

ps. If you enjoyed my unreal tutorial things, write “cake” in the post. If I get enough cake, I’ll start making more of these…maybe.

looks great, appreciate the work you’ve done.

Have you considered having the character shuffle their feet to turn instead? It never seems to look quite right, but I worry that players would get very irritated at not being allowed to turn in place.

You mean make the character turn around (+animanion) when the player reaches the sight limit?
Because when you are moving the character you can go full 360. This stays only for standing still. Also when you reach the limit, you can always turn around with the keys.

Also since when does Muad’dib, known to us by the secret name Usul, spend his time on software forums? Don’t you have an empire to rule?

Thanks for sharing. I decided to play around with this, but due to my complete lack of experience with working with UE animation graphs, I’m having some troubles getting the Head Rotation bit to work. I’m sure I’ll figure it out sooner or later, but perhaps posting a few more screenshots, a video, or, better yet, the project files themselves is not such a bad idea after all.

Well if you need help, post some more info. Just saying you have a problem won’t be enough to figure out the solution :stuck_out_tongue: (kinda why alcoholics have those meetings)

ps. Updated the animation tut. Check the note if your character doesn’t stop moving.

I have a fair understanding of the code, and everything looks pretty much functionally identical to what you have on the screenshots, but the head just won’t turn for some reason. Could you perhaps post the wider version of the TurnHead Anim Graph screenshot? Is it the main graph? Perhaps, being unfamiliar with anim graphs and all, I’m plugging the transform code someplace else. Other than that, I have no idea at the moment. Gotta spend more time on debugging what goes wrong.

I just followed the Walking Backwards tutorial, but I can’t seem to get it to work. It’s highly likely that the issue is user error, but the problem could be that we are setting boolean variables for “Orient Rotation to Movement” and “Use Controller Rotation Yaw,” but we don’t ever input logic for getting those values that we set. Any guidance there would be greatly appreciated!

The anim graph from the head turning tutorial is located in the Third Person Animation Blueprint.
This is the main one. To get to it you have to click the AnimGraph text in your ThirdPersonAnimBlueprint under the “My Blueprint” tab.

Here’s the screen of the full thing + the settings for the modify nodes.

If this doesn’t help, you could always post some screens of your script.

Also try to make the head and neck rotators public.

Not sure what you mean, but the logic determining how the values will be assigned happens in the screenshot above itby the branch, checking if the player is moving forward.
Also, make sure your casting works properly there. I always set a print string to the cast failed exec.

Couldnt you just uncheck “orient rotation to movement” and check “Use controller yaw rotation”? so the chracter would always face the camera direction?

What I’m saying is that if we “Set” these boolean values:

Then it stands to reason that we need to “Get” them somewhere…right?


EDIT: The tutorial mentions where to “get” the “Walking Forward” boolean, so disregard that in my screenshot.

(in other words: They work directly on the character)

Ha there we go. Thanks for clearing that up for me!

This works really lovely! Gave it a try and it is running really smooth, even though it doesn’t have all the features I need in the end it was a great push in the right direction! Thanks for sharing this!

Cool. Glad I helped. If you figure some neat stuff out on the way, feel free to post it here.

Sure thing! :slight_smile:

As a beginner to blueprints and making games in general. Do you have any plans on making this a simple tutorial for new people?