Rotate the view/camera relative to the player's rotation?

At the moment, my character’s mesh rotates to orient itself to match the normal of the ground’s surface. This is because the character is to later be able to walk on walls, ceiling, etc (hopefully). The camera follows the orientation of the character as well. The problem is that the camera seems to rotate in world space (even though the world looks tilted as it should, the view rotates as if the player is still standing upright) instead of relative to the player. This is especially apparent when upside down, as all of the controlls are inverted.

Is there a way to set the viewport to rotate relative to the player’s orientation? I have tried switching the rotation of the camera from Rotation to Absolute Rotation, although this messes things up even more. There’s probably something obvious that I’m missing.

Thanks for any help!

probably you have set the camera to ‘Use controller rotation’? Otherwise I think it should rotate relative to the Parent component. try un-checking that option.

Unfortunately, this option was already set off. I did some more testing, and I have realized that the camera does rotate locally, but actually the mesh seems to incorrectly rotate. When the character is looking parallel to the slope, the roll of the character is correct, however when I change the yaw to look adjacent to it, it rotates like the character is upright, and makes character’s pitch incorrect.

So it would seem that the character’s yaw rotation itself is turning on the world space, or the character’s pitch just isn’t following the rotation change. Would you know how to fix this? I’ve tried toggling the ‘Use Controller Rotation Pitch/Yaw’ but no effect seems to occur. I’m using the default ‘MyCharacter’ blueprint movement setup from one of the templates if that helps.

Thanks for the help though!

I’ll create a sketch to better visualize what is happening.

Alright, hopefully someone can understand what is happening from this quick drawing. Again, I probably have some setting incorrectly set or something.

Here are the blueprints incase they help. Sorry for creating seperate comments, comment doesn’t want to submit with more than two images.

I don’t quite understand the first image. Can you post a screenshot from your actual game?

But looking at the first blueprint, I have a doubt (I am not sure). If you are turning your character around, I think you need a new Forward Vector and Up Vector. You see, if your character was standing on the ground up-right and then changes his rotation so as to walk on a wall (ie a 90 degree rotation in Pitch), then his Up vector has changed obviously, but his forward Vector has also changed (due to 90 degree picth). His forward vector is now parallel to the wall’s tangent.

But in your blueprint, looks like you are setting the same Forward vector as the target Forward Vector.

I understand what you are saying, and it sounds correct. However, I do not know how to get the new forward/up vectors after the initial rotation. When I attempt to apply it myself, everything messes up, so I obviously have no clue about what I am doing. I am still very new to traces, normals, vectors, and rotators anyway.

Thank you for your patience with me!

This is just a guess, but I think try setting Forward Vector to the tangent of surface and Up Vector to the normal of surface. After that you can re-calculate the right Vector from these two vectors. I have a feeling that this should work correctly.

The problem is you only know the normal. And given a normal, there are infinite number of possible tangents. So inorder to get one among them, you need to calculate the cross-product of the normal and a vector that isn’t parallel to the normal. However you can do a simplification, you can set the arbitrary vector to a vector calculated from your current forward vector. This is achieved by rotating the current forward vector by the difference between your current UP vector and the surface normal rotations. That should give you a vector parallel to the new surface.

Now you have both the new Normal (up) and Tangent (Forward). You can calculate the Right Vector from these two.

NOTE: surface = wall/structure that you will be standing on.

Let me know if this works

Well, even though you thoroughly explained what should work, I still can’t get it working. I do believe that I am just setting it up incorrectly. I guess it’s about time I relearn calculus before I continue to attempt this.

Thank you for trying to help though!

Its not calculus, its Vector algebra :wink:
But hey don’t give up. Can you try to upload this blueprint of yours somewhere so that I can work on it. I might be able to come up with something.
OR you could give me the exactly how you have setup the project and inputs, physics configurations…and I will try to recreate them in my PC.

Unfortunately, I just left home for the weekend. But I could share it with you when I get back (probably Monday).

Oh, and I checked the UE4 Roadmap and one of the cards is titled: “Arbitrary Orientation / Gravity Direction for Characters”. Is this what I’m looking for? I can wait to implement this if this feature will be added internally.

Hello. I have the same situation. Have you been able to resolve this issue?