How to Make Head Follow Camera - UE4 Tutorial
ฝัง
- เผยแพร่เมื่อ 25 ส.ค. 2024
- I've seen many overly complicated ways to make the head follow the camera in a third person game, so I wanted to offer my fairly simple solution. Complete solution with additive rotation which blends well with any animation. Furthermore, it's all done by only using the animation blueprint.
Enjoy! - เกม
OBS! You should run your "Follow Camera" reference through a '"sValid?"-node before using it in the "HeadFunc" since it's not inherited by the character class. It will still work if you don't but you will get an error.
To elaborate; when you look inside the AnimBP's Event Graph you see the first thing which is done is to run the player through an "IsValid?" node. Do this with the follow camera node in the HeadFunc :)
@Havis yes it is
use anycamera you want
How exactly do I do this? I get what the overall idea is, but I'm still pretty new to UE4 and I'm using the latest version, 4.26.
THXXXXX!!!!!
Thank you still helping 2 years later.
When your looking behind your character there's a little detail, the head moves too fast and it does not seem natural, the way of solving it is using a "Finterp to" before set the Z (Yaw Of the finall setter), you have to promote to a variable the Z of the Finall Setter and Set it on the Flow before the Finall Setter then use the Finterp to before the Clamp of Z and put the Variable promoted before on "Current" and then put on "Target" the result of the "Clamp", after that Set it on the Setter of the Promoted Variable in the flow and connect that to the Finall Setter
This works! So drag off the yaw/z from the last set head rotation node and type Finterp to - for the current of the interp node, drag in a get head rotation and split the rotator and connect the z/yaw to the current. The target connects to the last clamp angle node output. For delta time, type "get world delta seconds" node and connect it to the delta time, and for the Interp speed set it to 10.
@@ozdev Bless you
@@ozdev The results are perfect now, thanks :)
@@ozdev thanks for this!
@@ozdev perfect.need to comment this to the general comments so nobody else has to search through.
for those who had errors making follow camera valid like me, you can right click on the target -> follow camera node and at the bottom there is an option called "convert to validated get"
just did it. its working perfectly
Good video, but there's a bug when you see down with the cursor, the head starts moving really fast in the Y (Pitch of Finall Setter), the way of solving it is setting in the Clamp before the Setter on 0 on min and 0 on max (In the head movement we dont need that)
Hey man, great video. I'm just starting out with unreal and this was so useful.
I was wondering what I could do to have a smooth animation play when the player switches sides from the back (as it currently just snaps to the other side).
I was also wondering if there is a method of keeping the player head forward instead of left when the camera is in the back.
Also, when you look all the way down the character's head rotates oddly. A followup video would be great!
Thanks
Hello there, good questions! If you are learning i think you should try to fix these yourself. I will however give you some pointers.
1. By smoothing you mean not instantly switching direction. Yes, I would do this by restricting the max difference in angle per tick. Limit the value using a clamp depending on the current angle.
2. By using a 'Branch' you can set it so when the camera is over a certain YAW rotation he will look straight ahead instead.
3. The head movement in real life is a combination of neck and head rotation. You could try applying some of the rotation to the 'neck bone' also :)
If some of these seem vague I will gladly answer any question.
@@LouSimonsen Hey man, it's a little late but I saw this comment about making the head turn smooth and I just can't figure out where to put the clamp to limit the current angle! Some help would be appreciated, thanks in advance!
Can you make a system where the ai focus on the head but it's send from c++ to blueprint like you did so it's not head ai can focus on whatever you want it to
Is there a way to make it smoother when walking/running back at the camera. I only get my character head snapping left and right regardless of the extra clamp, which I am fine with if I could get a smoother rotation rather than snapping. And like Lou said in order to get rid of errors in newer version, in the headrotfunc after the call to character add an 'isvalid' in there, then drag a link from the follow camera into it, nothing else has to be connected other than the main exec that goes to the set node at the end. this gets rid of the error
This is a couple years old, and Im working in UE5 atm, I cannot seem to get it to work (newb) I get a error after runtime, none in the set headrotation. Im prob doing something wrong.. although it is a pretty simple setup...
Thank you!
how do you get "FollowCamera" at 2:10, i don't see this, i see it's a variable but i don't know what type of variable it's, im new in ue4 pls can u help me
In case you're still wondering, FollowCamera is just the default name given to the camera for the third person character blueprint's camera. If you made your own character blueprint it might be called "camera" or whatever else you chose to name it
Still a good tutorial! Thx :)
You're doing God's work friend
Thank you so match
Great, thanks !
How come my characters head is looking directly at the camera?
I’m having the same issue, it’s like my character is looking in the opposite direction of the parameters set in the video
@@Perkins.Garage im just commenting incase someone comes along with a fix :D
@@NoonCall have u tried increasing the x value for the rotate vector in the HeadRotFunction?
Probably too late, but I was able to fix it by changing the subtract node to an add node.
Thank you ;)
a much easier way is just to on begin play: -- set 3rd person camera active -- set controller rotation yaw to true. done
which looks shit
great tutorial but how can i make my meshs head look at the player
for example i have a turret model and i want its head to look at the player
Use the "Find Look at Rotation"-node to set the head rotation :)
This setup suffers from gimbal lock, any suggestions on how to get around it?
prevent the head from bobing fully vertical, a lot of games are locking the lookup at 10 degrees from pure vertical
can barely hear you
max volume
am i the only one where the head is turned towards the camera instead of away from it?
Hi, i tried to do this but the camera stock on top of the character looking down i have no control of the camera, what do you think that could be the problem?
Well, this function only gets information from the camera in form of location and such, but it never alters the camera information. So the issue will lie somewhere you have used the camera to get information and accidentally set the information to something new.
I would check every place where you have a reference to your 'camera' in your function. I would also check everywhere you have a reference to 'control rotation'. Check if you used 'set' instead of 'get' or if set your control rotation to something.
@@LouSimonsen Hi, you were right it was a bad setting in the camera, i am trying that the camera direction make the character rotate as well with a delay (the head turns to a limit then the hole body turns)
Alejandro Montenegro Reyes I’ve made a similar setup since i made this video, the animations for it should be in the download file as well. I made it so when character hit 0 velocity (stranding still) it would save the rotation and once turned 90 degrees from that it would play the ‘turn Body’ animation. How do you do it?
@@LouSimonsen i am still trying to figure it out, " it would save the rotation and once turned 90 degrees from that it would play the ‘turn Body’ animation." that is my idea too but so far no luck
@@alejandromontenegroreyes724 Maybe if vamera default location is 0 and you make the transition say if "camera location "
How can you make it so he doesn't look to the side when running front/back
watch promethius head rotation tutorial
adjust your clamp sizes
@@YunethAlwis link? channel name? That name wasnt found. And got a bunch of movie spam
@@kenalpha3 dang, he has renamed the channel i believe
now its UE4 Poseidon,
th-cam.com/video/n-GWV9gZ2Zo/w-d-xo.html
How can replicate this for multiplayer? currently I can only get the client to replicate to the server
Ok, this requires more knowledge about multiplayer systems than this head setup, but i will give you some pointers.
- The variable has to be communicated to the server, depending on wether or not the player is the server already. The node you need here is called "Switch Has Authority" and can only be accessed within a character_BP, not anim_BP (For test of these systems i recommend testing with "Run on Dedicated Server" switched on)
- You have to do this by replicating the Head Rotation in the Character_BP NOT the Anim BP. Fastest way to do this is just to make a custom event in the Char_BP which recieves the head rot information. And then you cast to the char BP inside the Anim_BP to get this information again.
- Something you need to be vary of is that the player controlling the character sees the constant update of the Head Rot and the interpreted Head Rotation is what other players see.
- Doing something like this similar to "Aim Offset" systems. So you should prob look into how people replicates these systems :)
@@LouSimonsen Thank you!!
How can we account for character body orientation as well?
What i mean is that if a character is in prone, the head turns in directions as if it would be standing, it would be nice if the character attempted to tilt head and rotate head towards the cameras direction. Since i suck at math, my idea was to actually edit the Epic skeleton and add a eyes bone and use IK to rotate the head in such way to always try and rotate head where the camera is look at.
It can probably be achieved with rotations but again, i suk at all that vector and rotator math. xD
So a tut would be nice for that. Thanks anyway!
What you are looking for is called 'Aim Offset' :)
@@LouSimonsen Sorry, don't know what you mean. 😅
NxT Aim offset lets you attach animations to certain rotation, for example making a 3rd person character aim upwards. You could use this in a prone to make an animation of how to rotate when looking bsckwards. Try looking at tutorials on youtube for it 👍
@@LouSimonsen I guess but I wanted to make it completely independent from any animations. I'll fiddle around it some more. Because the character should have peeking, prone on back, sides and belly, making it mesh orientation aware would be technically a better implementation then animation dependent. Note I'm not using any anims yet, just rotating the char mesh around trying to achieve dynamic head movements. Worst part, I know it's possible just I suck at math so bad, man that's sad. 😭😂😭😂😭😂
But thank you so much for so fast feedbacks!
Btw, the aim is to make an mgs4 style player movement system. Tho prone is turning to be a pain with the collision capsule and all...
Thats a kinda fast tutorial ngl🤣💀
BRO SPEAK UP