Announcement

Collapse
No announcement yet.

How to switch between free rotating camera and fixed camera while aiming down sights in 3rd person

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

    How to switch between free rotating camera and fixed camera while aiming down sights in 3rd person

    Hey everyone, I'm currently working on a little demo scene and now I got stuck with some camera rotation issue.
    I actually want to archive something that is really common in modern 3rd person shooter games but I can't figure out how to solve it.
    So here is the idea:

    While exploring the world the player should be able to freely rotate (mouse/right stick) the camera in every direction and arround the character, also the character movement should also be totally free. Like in most common 3rd person game, right?
    Click image for larger version  Name:	DeusExUnrealScene--Unreal-Editor-07.03.2020-17_41_44.jpg Views:	0 Size:	558.0 KB ID:	1730060
    But when aiming down the sights of a gun the camera should zoom in and switch to a shoulder view (already implementet)
    But while the player is pressing the aim button I want to controle the direction the player is aiming at and let the camera be fixed in shoulder view.

    Click image for larger version  Name:	DeusExUnrealScene--Unreal-Editor-07.03.2020-17_40_14.jpg Views:	0 Size:	444.9 KB ID:	1730061
    I figured I can archive both effects while switching of/on "use controller rotation Yaw/Pitch" in the pawn menu of my 3rd person character BP.

    Click image for larger version  Name:	PawnControl.JPG Views:	0 Size:	18.7 KB ID:	1730059
    Question is:
    How to switch between these two seetings in a Blueprint via bool "isAiming" for example? Is it even possible or do I need some kind of workaround?
    Any help on this is highly appriciated!

    Note: I'm a 3D-Artist, so please bear with me...
    Last edited by MaryMassacre; 03-07-2020, 02:28 PM.

    #2
    Create a function that sets / unsets the required variables. Now call this function when you press the "Aim Down Sight" button. On button press, set the variables to use the Shoulder Camera settings. On button release, set the variables to use the Third Person settings. Or, if you want to use "toggle style", use a flip flop node instead of Press and Release.

    Comment


      #3
      Thanks for you reply! We'll that is actually my problem. I haven't found a way to get access to these settings via Blueprints or is there a particular node I'm not able to find?

      Comment


        #4
        Ok, got it working. Still has some room for improvement but this is the recent set up for anyone who is in need for it.Click image for larger version

Name:	Unbenannt.JPG
Views:	56
Size:	225.3 KB
ID:	1730722

        Comment


          #5
          Click image for larger version

Name:	capture.jpg
Views:	52
Size:	93.8 KB
ID:	1731648
          There is a simpler way. Assuming that you are using Third Person Template, use the variable as follows
          1. "Use Pawn Control Rotation" from "Follow Camera" component
          2. "Use Controller Rotation Yaw" from the "Character" class itself
          3. "Orient Rotation to Movement" from "Character Movement" component
          Setup as shown in the image. Basically what it does is set the camera to be fixed to the Pawn movement (specifically the "Capsule Component") and forces the Pawn to lock to mouse input.

          The above image shows implementation as a function, to lock the Camera you will set the function's Enable input to True

          Comment


            #6
            Yes, I'm using the template. Thanks a bunch for sharing, thats way better then what I had!
            I came up with this yesterday, wich seams to also work very well but will def try your solution:Click image for larger version

Name:	Unbenannt1.JPG
Views:	28
Size:	333.2 KB
ID:	1731684
            Attached Files

            Comment

            Working...
            X