Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:
    https://www.youtube.com/watch?v=IWSBYUPWMk0&t=17m20s

    #2
    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 ).
    Attached Files

    Comment


      #3
      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

      Comment


        #4
        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

        Comment


          #5
          I will try that. Thanks. I probably wouldn't have come across that 'feature' 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.
          Last edited by Jimminy_Cricket; 08-19-2019, 03:29 AM.

          Comment


            #6
            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.

            Comment


              #7
              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...

              Comment


                #8
                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.
                Last edited by Jimminy_Cricket; 08-19-2019, 08:02 AM.

                Comment


                  #9
                  Jimminy_Cricket Didn't know about 'is falling', nice, might try that...

                  Comment


                    #10
                    Originally posted by ClockworkOcean View Post
                    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 ).
                    Thanks a lot!! Sorry for the late reply.

                    Comment


                      #11
                      Originally posted by Jimminy_Cricket View Post
                      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.
                      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.

                      Comment


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

                        Comment


                          #13
                          Originally posted by xpgained View Post
                          What about for detecting if a vehicle is falling.
                          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!

                          Comment


                            #14
                            Originally posted by ClockworkOcean View Post
                            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 ).
                            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?

                            Comment


                              #15
                              ..
                              Originally posted by tapirtoon View Post
                              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?
                              Originally posted by ClockworkOcean View Post
                              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 ).
                              ...bump...

                              Comment

                              Working...
                              X