No announcement yet.

3rd Person Camera - Best way to automatically have it adjust pitch

  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Use line traces. one ahead of player one behind.
    As result you should get 3 points in d3 space: 2 trace hits and one for feet location of player pawn. Get Z values of both trace hits, and player feet location. Calculate both angles: for trace ahead and behind player.

    You will have 4 cases:
    player goes uphill, player goes downhill - just calculate slope, for eg difference of both hit Z values to where player feet are.
    Player is on top of hill - i think default angle.
    Player is in hole - pick forward trace Z value to calculate slope, (fake rear with negative Z of forward one).

    So when you have those values, do average of forward angle and rear angle. Multiply that by some parameter. An you will have desired rotation of camera.

    Now best way to manage camera imo:
    add "camera arm" enable some decent angular lag, keep velocity lag low.
    Connect camera to that arm.
    Remember arm default rotation as some value.
    Add your calculated angle (from traces), to camera arm rotation.

    And because you enabled lag for camera arm, it should move very smooth.

    PS. you can also add a bit of such camera rotation (slightly turn it to sides) for situation when player walks along slope (ie. slope is on left - right direction)

    Leave a comment:

  • 3rd Person Camera - Best way to automatically have it adjust pitch

    Posted this in another thread, but this might be a better place.

    So I am trying to make my camera automatically adjust based on the slope of terrain that my player is on. Flat ground will keep the camera where it is, going up a hill will lower the camera a bit, and going down a hill will raise the camera a bit.

    I am relatively new to Blueprint and I think I have the logic correct (in my head at least), but I am having trouble making it work correctly in Blueprint.

    I am doing all of this in my character controller, and I originally started with the 3rd Person Template, if anyone has any guidance or suggestions I would greatly appreciate it.