Announcement

Collapse
No announcement yet.

Player movement that is both reliant and independent of camera's vector

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

    Player movement that is both reliant and independent of camera's vector

    This may be complicated to explain but I'll try my best to get it across and hopefully you can help me. What I'm trying to do is have a player's movement seperate from what the camera is looking at while having the direction you press to move the player rely on where the camera is looking at. For example, if you're moving forward and you rotate the camera, the player wont actually move to the direction the camera is facing, rather he will only move relative to what direction you are pressing. If you have the player running backward, release the direction, rotate the camera so that its facing the direction you're running, as soon as you press forward, you will continue going in that direction rather than it read backward. If anyone can understand what I'm trying to say and can even help, I would greatly appreciate it. Thank you very much.
    Origin of Storms

    #2
    Did you ever resolve this? I too am looking for a way to have the camera controlled with the mouse while the player movement is controlled with the keyboard.

    Comment


      #3
      Unfortunately I never figured this out.
      Origin of Storms

      Comment


        #4
        Hello,
        A better definition of keys effect would help figuring it : up key : moving forward, down key : rotate 180, left right : rotate 90 (and wasd), mouse as usual around player ? Wheel distance player camera ?

        Comment


          #5
          Your character can move separately from camera if you not using camera orientation when add movement input.

          If you look in character BP for third person template, you can notice that it use controller rotation for movement input direction.
          Click image for larger version

Name:	2015-01-30_1724.jpg
Views:	1
Size:	107.8 KB
ID:	1065778

          You can remove it and use direction specified by yourself.
          Click image for larger version

Name:	2015-01-30_1728.jpg
Views:	1
Size:	106.4 KB
ID:	1065779

          Also you should check "Orient Rotation To Movement" in character properties, if it's not set.
          Rocketeer

          my portfolio
          my youtube

          Camera Volumes System
          Procedurally Instanced Meshes
          Simple Portals
          Water Flow For UDK
          Setup Swarm

          Comment


            #6
            That's one part of the problem as a whole.

            The second part is moving toward the camera orientation when actually moving. In the third person template, you move with the camera even when movement isnt being input.

            I'm trying to figure out how to add movement toward camera direction when inputting but continue with momentum toward the direction you're already going regardless of camera when movement input isnt being added.
            Origin of Storms

            Comment


              #7
              I really can't understand what are you talking about.
              Can you provide any video with similar game mechanics?
              Rocketeer

              my portfolio
              my youtube

              Camera Volumes System
              Procedurally Instanced Meshes
              Simple Portals
              Water Flow For UDK
              Setup Swarm

              Comment


                #8
                Do you mean like a Resident Evil/Biohazard-style static camera with a movement system relative to said camera? Obviously when the camera changes its position, you don't want the player to have to quickly move the joystick to the new direction to avoid going back the way they came. Silent Hill 2's 2D movement mode solved this.

                I had to solve this myself in Unity a while back. Instead of making the player move in relation to the Camera, I have the player move in relation to an empty object with a transform component. Its starts having the same orientation /location as the camera, but as long as the player is holding a joystick direction, this does not change. This allows for the camera to change position and orientation but the player can keep the joystick held in the same direction. When the joystick is released or moved an appreciable amount in a different direction, this empty game object then snaps to the new camera transform.

                >Game Initialized, Camera Relativity Controller (CRC) is given Camera's transform.
                >Player Enters trigger that changes Camera's transform.
                >Trigger sends message to CRC that the camera's position has changed.
                >CRC remains at its original transform, but now checks at an interval to see if the input values from the joystick change by an appreciable amount.
                >Player lets go of the joystick or intentionally moves in a different direction
                >CRC snaps to Camera's new transform
                >CRC stops checking for player's input
                Last edited by Jared Therriault; 01-30-2015, 02:17 PM.
                Procedural, modular, on-the-fly animation - iTween For UE4
                - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

                Runtime Datatable
                -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

                Comment


                  #9
                  I know I'm trying to make it sound much more complicated but what I'm really aiming for is a camera like normal 3rd person camera systems. You hold forward and its forward based on the camera. If your character has momentum and you stop pressing forward to go forward, the character will continue going in that world direction regardless if you move the camera or not. Basically when you ARE inputting direction, its based on the camera. When you're not inputting direction, your movement wont be changed by a camera move.
                  Origin of Storms

                  Comment


                    #10
                    The solution is pretty simple really, you gotta find the forward vector of the camera, not the player. So if you have a camera locked in space, it will know which axis to move on through by its POV. So in my case i have a blueprint that has a camera, with a trigger box and thats how, when the player overlaps it changes to the camera of that blueprint for the new view. I then send a message to the playerblueprint, and let it know if the player is inside the camera. If it is..then use the camerage manager forward vector.

                    Click image for larger version

Name:	cameraForwardVector.JPG
Views:	1
Size:	90.0 KB
ID:	1071164

                    Comment


                      #11
                      Well I know this is an old thread, but I think the final answer is quite a complicated way to do this, and I've seen this question many times, but I've never seen my answer, which I like, so I think other people should like it too.
                      My version is quite universal, as far as I can tell. It's the actual default "Movement Input" block (in the ThirdCharacter event class), but just modified to change the "Get Control Rotation" node to "Set Camera Rotation" with a "Get Player Camera Manager". If you want to have some multiplayer features, don't forget to change the default player index value in the "Get Player Camera Manager" node to something like the actual player index.
                      Click image for larger version

Name:	UE4Editor_2018-04-20_00-18-54.png
Views:	51
Size:	176.0 KB
ID:	1463760 Here is one screenshot. It works like a charm!
                      ‚Äč

                      Comment

                      Working...
                      X