How to make mouse input axis move the camera relative to the pawn rotation?

Simple project where the player is a ship and I want the player to be able to move on all axis and rotate in a zero g environment. (This all works)

The problem is once the player is upside down all the controls get wonky.

I have wasd setup to take the camera’s vectors. And it seems to work but my mouse get’s inverted as it is tied to the world. Somehow I need the mouse movement to be relative to the pawn’s rotation that way when you look right it will always be right, relative yo your rotation. But now if I look right while upside down I’m looking left to the pawn but right to the world(if that makes sense).

As the player has complete freedom of movement: forwards/back, left/right, up/down, rotate left/right. And it is quite disorienting to try to shoot and move or maneuver when all the sudden the movement isn’t relative to you when it appears that way when your rotation is “normal”.

Any help appreciated. Thanc.

Edit: Trying to think of a better way to explain the character should always have the front of the ship on screen like in cod when you always have your characters hands and gun in view. When you move, roll or anything; the character’s hands and gun would always be bottom center of your screen no matter what. With this in mind wasd should always move the same and the mouse look should always be the same, as should the ascend/descend functions I have for my ship.

Everything works fine if the character is not rotated, but, again; the controller doesn’t take the pawns rotation into account so when you start to rotate the controls get messed up and will invert once you’re over a rotation threshold. This isn’t what should happen. I need some sort of way to force the players controller to take the pawns world rotation into account so it will always be the same movement no matter where or how you are in a zero-g environment.

And I guess a smaller issue if the player is rotated 90 any way. The ascend/descend functions break hard. Just think of it as a jump/crouch. When the player is rotated these controls break because “left” to the player may mean going into the air or vice versa, when the world isn’t getting rotated so the up/down sill takes you up down relative to the world not you.

Thanc again, any help appreciated.

Edit: It seems from my understanding this is a result of “gimbal lock” I am trying to figure out anyways around this but it seems quite silly that quats aren’t already exposed to bps and you should be able to set a pawns rotation axis regardless anyways… Why is everything force aligned to world?

Just to check, are you the ship, or can you see the ship in the camera?

It is “first person”. You are the ship and the camera is attached from a boom but is very short just so you can see some of the ships front part.

Right. I think you might get some mileage by only using AddLocalRotation nodes.

So never set the position of the ship in an absolute sense, always just add ( or subtract ) local rotation.

Well, I use world rotation for the ship to rotate but the camera is stuck relative to world not the pawn, add local rotation for a mouse input doesn’t seem to help with much. I’m strictly trying to control the camera rn my ship moves exactly how I want.

I know what you mean about the controls. I think you might have to rotate the boom with the ship ( what it would really be like in 0g ). Otherwise, it means swapping the meaning of the controls at some arbitrary point during the rotate.

Well I rotate the entire pawn mesh itself, the boom is parented to that so everything follows when the ship is rotated. Separate them out and rotate locally?

Oh okay I didn’t think about separating out my controls I’m just using the basic left/right with the -1, 1.

I don’t think so, it’s logical that the camera goes with the ship. That would be your experience in space.

But I’m wondering if you couldn’t make, for instance A, is always add location rotation left. For example…

1 Like

Ah, no, that’s what I was trying to say above. This space thing works really well if A is always add local rotation in Z ( D subtract ), etc…

AddActorLocalRotation.

1 Like

Well I mean the rotation works but once I get turned over my og problem of the mouse is inverted still happens.

This is addactorlocalrotation, “self” and the axis is *5 into the x(roll). Y and z didn’t behave properly at all.

Yeah that’s my initial issue, if the player gets rotated everything gets inverted. My first thought was to somehow add the players offset to the player controller or change the inversion but I’m not sure if the nodes allow you to do that and attempting to add an offset to the controller seems to break my rotation entirely for some reason.

I don’t think that is gonna work. I don’t know If I’m misunderstanding or if something else on my pawn is stopping this from working.

For all intents and purposes the ship is just the same as any first person character so in like call of duty when you’re in zero g and upside look right will always look right but the player isn’t rotating they are looking and the player can still rotate the character to any orientation with keys.

I’m really not trying to come across as rude or anything but it could be because I’m dumb and can’t explain it well enough but I don’t think a rotation is what I need. I’m just trying to make the character be able to look around ‘correctly’ regardless of orientation.

Buuut since rotation look is tied to the world not the apwn when I’m upside down i’s inverted

I guess up/down is bound to get switched, right?

No, I take that back. I’ll have to try coding something myself…

I just made a pawn. Nothing in it except a camera and:

It works the same at any pitch… ( it only does pitch ).

1 Like

Yes, maybe I’m not getting it…

1 Like