Input Direction With Camera Relation

I am trying to make my own 3rd person character controls by having the camera separate from the actor and having my character move in the direction I input. I can’t even seem to figure out how to get the necassary 180,-180 or 360 values to do this with… I got the camera moving independently though like below.

Currently just trying to get the proper rotational value for the input direction depending on my camera rotation around the player and making it so that an arrow component I added faces that direction of input. So If I look directly behind the character and press right + forward I get a rotation that’s back + left of the actual characters facing for example. I don’t want to manually set just the keys for directions either as analog sticks on a controller would need to work for this also.

Anyone got any idea? I am so lost. Even if I used the default, I still would have needed this.

1 Like

Just trying to understand what you want. Do you want your character to move for example north south east and west? Or move left right forwards back relative to the direction of the camera?

All relative to the camera’s direction. Get full 360 degrees around so that keyboard and mouse OR even controller analog can pull it off at any angle even between the main angles like forwards, backwards, left, and right.

Main problem is getting the proper angles, but something is starting to make me feel like I am over thinking it the more I try to explain. The rotator stuff has been difficult some reason to get my head around. xD

Essentially anything I press should make my character move, but the character will turn to face what ever direction I am pushing input towards, I am trying to figure out this.

Maybe I can ask a better question.

Do you want the character to move like an FPS move forward/back and strafe left/right?

Move like old Resident Evil games (aka, tank movement) move forward/back and rotate left/right?

Or do you want like the default third person template controls move and rotate forward/back, and move and rotate left/right?

Just asking how you want the movement to be, ignore how you want the camera to be. Doesn’t matter about the inbetweens (Forwards + Left) I’ll be able to give you an answer that will take those into account.

Essentially like the default does normally, but trying to figure it out myself and improve my abilities + gain better control of it potentially. Maybe I am just being dumb and might as well use the default? Figured it would be better to learn how it works and maybe it actually can be made a bit better, smoother, esc… Can’t even figure out the rotation. xD

Kinda like any modern 3rd person like zelda, mario, esc…

The Third Person Template way is exactly the best way to do it. At least within the Character class, there is a lot of control pre-built into that class. You could make a custom Pawn from scratch where you build in all those things. But as good as it is to know how to do those things, you don’t really need to invent the wheel twice.

Use your time to focus on the things that aren’t already built, you’ll learn a lot along the way. Vectors and Quaternions (rotations) are hard to wrap your head around to begin with. Epic did a Maths video a while back focusing on Vector math, but Quaternions are another thing.

Here’s the math video

If you’re using “Add Movement Input,” then that’s a function on pawn movement component that expects a vector in world space.
If you use the current camera, and get its actor rotation, that will give you the rotation in world space.
If you get the “right” and “forward” vectors of that camera rotation, they will be expressed in world space, too.
So, you can do something like:
On input right/left, get the right vector of the camera, set Z to 0 (to make it in the plane,) normalize it, and then multiply by input axis value. Use this for AddMovementInput.
On input forward/back, get the forward vector of the camera, set Z to 0, normalize it, and multiply by the input axis value. Use this for AddMovementInput.

1 Like

You just need to get the current camera and then use its forward or right vector to determine the movement vector. Then set orient rotation towards movement to true on the character.

You just need two things, the X and Y values of the stick input, and the actor or component that is your direction reference.
In my case, in a third person game, it’s the camera, then I make this simple calculus, to rotate my actor to the correct direction before playing the roll animation.