I’m working on getting a third person character to be able to fly and have 6DOF movement. So far, I’ve gotten past gimbal lock using quaternions and I can successfully get the character to roll left and right and get the camera to roll with them.
However, the problem comes when I try to move the character’s yaw and pitch using the look input, it seems that the look movement is tied to the world rotation.
The result is that the player rotates -90 and the goes along with it, so the view from the camera matches the rotation of the player.
However, seen by the world up and left lines, when I attempt to move the look input pitch and yaw, this movement is still tied to the ‘world’ rotations (which has not changed), instead of being tied to the player’s new rotation.
Any advice or direction to tutorials would be of great help! Thanks in advance!
Note: I’ve tried disabling Use Pawn Control Rotation right after disabling Inherit Roll. This results in fixing the camera movement issue, allowing the camera’s pitch and yaw to rotate with input, however the pitch and yaw of the character’s mesh now rotates with the world instead of locally, so fix one problem create another. I’m thinking the ultimate fix could be here, but I’m not seeing it so far.
Dont use character. Dont use pawn. Make your own controller. In c++.
And do not use tick. Not even for prototyping.
What else? Oh yea, if you need this to replicate on a server you need to expressly look into how it’s supposed to be done hint, you wont find any best practice way within unreal’s free to use templates.
Ha, and last but not least: don’t even think about trying to use the engine’s physics - unless you swap to physx, then mayne you can at least think about it.
Come to think of it, you may be better off getting the starting code from something like Gdot or similar. You can find full on phisically calculated “flying” controllers out there - it just depends on what exactly you need…
Are you trying to create a rotation like a starship? If so, I guess you can just try using nodes like Add Local Rotation. “Yaw” (Delta Rotation Z) can be used to locally rotate the camera left/right, “Pitch” (Delta Rotation Y) can be used to locally rotate the camera up/down. You can also use “Roll” (Delta Rotation X) to rotate around the longitudinal axis. I don’t think you need quaternions at all with this node.
You would in order to prevent gymbal locking, but if you do the math for your system and truncate the angle back to 0 when over 380 you can sometimes get around the issue.
Problem is, Pawn can do this OK (ish), The character class cannot.
And then there is also the possible lack of replication…
Gave this a shot! It looks like this way won’t apparently let me rotate both the pawn and the camera at the same time though for some reason. Using AllLocalRotation allows me to roll, yaw, and pitch the camera correctly on its own. However, once I hook up logic to also rotate the pawn, the camera stops rotating. Tried hooking it up to a sequence as well as moving the logic to the inputs, same issue.
That’s confusing.
Your camera should be attached to the actor via a spring or similar.
Then you just make the actor move/rotate. The camera is just along for the ride.
Yeah that’s what I thought should happen, so my hierarchy is the character class has children mesh and capsule, mesh then has child spring arm which has child camera.
The camera and spring arm rotate successfully, but they don’t yaw and pitch with the parents, like the parents will rotate but the pitch and yaw will stay tied to the world up and down
Nha, If i really had to, I would just set the collision to be pointless, do what is needed via the mesh collision instead.
But if it’s down to that point, I’d just write my own character controller with what I actually need- you knoe, instead of wasting time and money on making some hack that was never supposed to work that way “work”… for 10 minutes before the engin breaks it.
I’m not as knowledgeable on UE, this is a personal project I’m working on to learn so I’m not spending money on it.
But I’d think, based on what I do know, that asking the camera to rotate in respect to the pawn instead of the world wouldn’t be a huge ask? Or is the camera motion ‘baked’ into the stock 3P character controller? The one I’m working with is largely custom, I used the 3P as a template but deleted all the logic from it in the BP and started from scratch, so not relying on anything UE starts you with in that respect.
Right, which it’s doing, the problem is that the yaw and pitch of the camera seems still tied to the world. Like if I’m rotated 90degrees to the left, moving the look input ‘up’ takes the character to it’s mesh’s ‘right’ instead of ‘up’.
Edit:
Some more information: I printed out the rotations and the up vectors for the actor, controller, spring arm, and camera. All seem to match, so shouldn’t the look input’s pitch and yaw match the up and right vector here?
No?
Because the character mesh is rotated to face X forward by default?
But aside from that, there are options that let you control what the camera does on the movement controller as well as on the spring arm, and on the camera too.
Hard to say what you need to check…
Its starting to sound like you want to implement a turn in place system though, so maybe look that up?