Help with Zero Gravity first person movement and rotation?

I’m learning to program using visual scripting Blueprints, and am trying to make First Person player movement for Zero Gravity planet-hopping, similar to Outer Wilds, with the player being able to roll the camera and spin 360 degrees pitch (head over heels), with movement and look rotations applied relative to the character at all times. This person’s video shows what I’m trying to achieve, but in First Person instead of third.

Every time I get any look controls working for this, the inputs always seem to apply relative to the world axis, so when rolled, the player doesn’t rotate in the right directions, and I encounter what I think might be gimbal lock, where rotating in certain axes doesn’t work at all.

I have my look inputs set up to store in variables like so:


With the roll input toggled by holding the E key.

My most recent attempt involved trying to use Quaternions, following this guide, but even with the new C++ code inserted and the custom player controller, the rotation isn’t relative to the player / camera.

I’d be so grateful for any help with this!

Add actor local rotation should be enough, without quaternions.

Are you saying, you want to rotate the player character, relative to the current camera position?

Hey thanks sm for your reply! Yes that’s exactly what I’m trying to do.

Sadly I’m not having any success with the Add Actor Local Rotation function, the problem seems to be the same: the rotations are applied in directions which seem relative to the world axis, which get pretty crazy / locked as soon as the player rolls.

Current attempt, without quaternions:

Here’s a video of the problem in engine if that’s helpful:

Any sense of what I’m missing here?

1 Like

Rather than getting the right vector of the actor, get the right vector of the camera.

Also, it’s probably better to actually do this inside the player :slight_smile:


Like this? I’ve moved it to the character blueprint and got the camera’s right vector but the problem seems exactly the same, still doesn’t apply the inputs relative to the player / camera, but creates the same look issues in the video above.

Any ideas what to try next? Really appreciate your help!

1 Like

Are you using the first person character for this?

I tried that. Can get a very nice floaty movement, move the direction the camera is facing etc, but can’t do things like roll. I think the character movement might be fighting it.

I made a pawn from scratch, and immediately got it to roll

pawn

Trouble is, you have to code all the movement. Not too bad. I put a zero length spring arm on the camera to get lag…

pawn2

I’d also take a look at the floating pawn movement component, which might help you… ( that’s what the little spaceship example is using ).

1 Like

I honestly can’t thank you enough. Just came back to this after a very busy period at work. Your suggestion of creating a new pawn was exactly what I needed to do. I’d been so bound to the First Person Character I hadn’t realised it would be confining the movement. Weeks of banging my head against the wall for such a simple solution. THANK YOU!

Now I just need to get my planet gravity system working again… Wish me luck!

1 Like

Good luck! :laughing: