Hello, I’ve been trying to get a character to move around independently from the third person camera, but to no avail.
What happens is when my character moves forward (so I press and hold “w”) and I look around with my mouse, it makes the character move according to where my mouse is looking. So if I just keep pressing “w” and look right, it makes the character move to the right as well.
I’d like to do something like The Last of Us 2, Hitman or Assassin Creed where you can move left or right, forward or backward and still look anywhere you want without having the camera direct where my character goes. Is there anyway to do it?
If you look in the Event Graph of your Third Person Character you will have a few commented blocks.
One is labelled Movement Input and contains your InputAxis MoveForward and the MoveRight events.
See the Get Control Rotation (target is pawn) node? Mouse over it and the tooltip will tell you ‘Get the rotation of the controller, often the view rotation of this pawn’. What it means in practice is that this is the direction of the camera.
So, replace this node with ‘Capsule Component’ followed by ‘GetWorldRotation’ and feed this into the Break Rotator node instead of the ‘Get Control Rotation’. Maybe that will suit you or at least get you started.
It worked! I didn’t think it’d be this simple, thank you so much! Admittedly, I am new to UE4 so I’m not sure what does what. Also, I happen to have another question, when I hold the “A” and “D” key makes the character move in a circle. How does one stop this from happening?
Well, it depends what you want to happen exactly. One thing you could do is copy the break-rotator and make-rotator nodes, feed them with the original ‘get control rotation’ and then feed that into the Get right vector. Now the character will turn to the right or left but only until they are 90 degrees to the camera.
But, they will still turn quickly. A simple way to slow them down is click on the characterMovement component and then in the details look at the rotation rate. You will see it is 360 as a default for turning about the z axis. Make it a smaller number. See what happens when you change the max walk speed or acceleration or friction.
Or, you could maybe combine the forward and right vectors to give you something in between so he only turns to less than 90. I hope you listened to your sums teacher.
It very quickly gets ‘not quite so simple’
My advice is use print and append statements a lot to find out what is going on. You can display on the screen or look in the log window (window-developer tools- output log) - what number is going into those scale value inputs of the Add movement component for example?
The basic animations with the default character are crude and it will not look fantastic. But animations is a whole big topic. Start with understanding the blend space.