How to make a simple up and down "head bob" for first person game's camera??

Hi, I’m trying to make a first person game, but I’m not how to go about making the camera go up and down as player walks or runs forward. I’ve looked up tutorials on YouTube for this, but they all seem to be trying to emulate a shaky-handheld camera look. It makes me feel sick/nauseous and is undesirable. I would like for the camera to look like in this game or similar:

@tapirtoon I made this chunk of code, I’m not saying it’s elegant ( AT ALL ), but it works, and give you the idea. You put the code in the first person BP ( I have show the position where ).

Hey Clockworkocean, I too was looking at how this could be done and so I tried your solution and by just changing a few of the numbers you provided was able to get the desired effect for my fp character. Thanks. Elegant or not, it works and that’s what’s important for me :slight_smile:

@Jimminy_Cricket @tapirtoon Lay in bed last night and realized: One slight ‘feature’ this code **might **exhibit is that the camera gradually changes height over a prolonged period of playing. The solution, is to set the camera height back to it’s original setting every time the loop hits 0 degrees.

Set the original cam height on BeginPlay :wink:

I will try that. Thanks. I probably wouldn’t have come across that ‘feature’ :slight_smile: for a while since my tests are usually in short bursts at the moment.
I also had to make one other adjustment and that was to not have ‘Move Head’ trigger if player was falling otherwise the player was bobbing when jumping or falling and it looked really weird.

Just out of curiosity, how do you check to see if the player is in the air? I have a solution I am currently using and wanted to compare and see if I should adjust anything.

@xpgained I currently use looking at the Z coord of the player on tick, if it’s changing by too much each tick, I know they’re falling. You can also do a trace from the bottom of the player for a certain distance. If you don’t find anything, they are either falling or flying…

Hey xpgained, you could do it different ways, but the easiest way, would be to cast to your character BP, get the character movement component and off that get ‘Is Falling’. When you are in the air from falling or jumping, it will return true.

I also have a jump mechanic with a bool which is true when jumping and false when not, so I could also use this if need be. But in my case, my first option i mentioned works great for me.

Or you can do as clockwork says. There are a few options depending on what you need.

@Jimminy_Cricket Didn’t know about ‘is falling’, nice, might try that…

Thanks a lot!! Sorry for the late reply.

What about for detecting if a vehicle is falling. Currently i’m using the vehicle movment component. I don’t believe I can check for is falling using that component. Currently, I am using the line trace method.

I’m not sure about vehicles, I haven’t played around with them. Line trace might be the way to go there.

You can try using the “Is Moving on Ground” check instead. It might just work.

Also, Just curious, why would you want to cause people with motion sickness to puke? PLEASE add in a “disable” setting!

I have no idea how to blueprint program at all at the moment.Can you paste it or give a link?

Do you know of any good blueprint tutorials to get started to better understand your code?

…bump…