How can I make the world rotate 90 degrees while approaching it in game?

I am very much a beginner, and I am not even sure where to get started.

Here is what I would like to happen:
when the player is next to the wall and presses a button or something - I would like to have the player’s world rotate 90 degrees. So now the wall is the new floor. So maybe the player’s gravity would shift and the camera would rotate with the player. Essentially I would like the player to run on all of the sides on the inside of a box.

Would I manipulate the gravity settings for the MyCharacter blueprint? Or would it be through the my level blueprint? Or both?

Thanks in advance for the help.

You could rotate the whole world 90 degrees if it’s not too big.

Thanks for the reply. This is one method to achieve this, but it is something that is restricted, like you said, by the size of the level. I was hoping for just the player to be rotated, because that would seem to demand the least amount of resources.

You’ll probably need to create your own gravity that changes direction depending on what way the wall faces.

You could try rotating your character so that its up vector aligns with the surface’s normal vector rotation. You can get the normal vector of a surface with the On Hit event (if your character has a blocking collision that generates hit events), or by using a line trace and then breaking the hit result.

If you’re not familiar with vectors, a normal vector is 3 floats (x,y,z), which represents a direction which is perpendicular to the surface.

I am finding it difficult to manipulate the gravity. I can change the gravity scale for the character with positive or negative numbers, but there is no way that I have found to make gravity go towards the wall. I am working on a way to at least turn meshes that I have made, and that seems to be the temporary solution. Thanks again for the help.

Hey there, to create your own gravity you could use the Event Tick node, and add a negative float multiplied by the time between frames Delta Seconds (output pin of event tick) to your character’s velocity in the local Y axis every tick. Then your character would have gravity in the direction of wherever its feet are facing. You can then change which axis you add that gravity to, to change the direction of the gravity.

I can only hope there’s an easier way within the engine already that I’m not aware of, but that’s how you can do a custom gravity.

Note: We multiply by Delta Seconds so that if the frame rate fluctuates, the amount we add to the character’s velocity scales with it. So if you’re getting 100 frames per second, the full gravity isn’t being added 100 times per second, you would be adding 1/100th of the gravity 100 times, adding up to the correct amount per second, independent of frame rate.

Okay, I am not sure I understand completely, but how does rotating the character affect the overall gravity of the level. I have played around with the constraining to planar for the character, but the gravity still makes the character want to stick to the floor. I have found that the player gravity only goes 2 ways, z-positive(normal gravity) and z-negative(head hits ceiling).

Thanks for your help, I am at least getting much better with floats and vectors now.

This is what I eventually got from what you said. I know it is not right, but I cannot seem to figure it out. I have managed to stick myself onto the other walls by manipulating the vector, but then I cannot seem to walk.

A couple of other things that I am not not sure of is:
What should the Gravity Scale be set to? or does it matter?
Just to make sure, I should be making this in the MyCharacter blueprint?
Do I use “Get Control Rotation” to rotate the player that I would like to rotate to?

Thanks again for your previous help, I really do appreciate it.

Gravity scale is only applied to the built-in gravity of the character controller. You can still use the value as a multiplier for your custom gravity if you wish, or create your own variable for that. Just make sure that your character controller has gravity disabled or the character controller will be applying downward force as well.

Yes, you can do all of this in your MyCharacter blueprint. There are more complex ways to implement a global gravity that applies to multiple objects, but if all you’re worried about is your character, then it’s fine to put all this inside MyCharacter and use Self as the target.

I will double check this once I’m at home, but I believe if your actor has a character controller, then you can use the Control Rotation. You can also use Actor Rotation.

For movement, you need to always be adding movement in local axis (which i think character controller does). Your character’s local X axis is always pointing forward, so you can add forward motion by using Get Actor Forward Vector, multiplying by a speed variable, and adding to your current velocity.

I’m not entirely sure how you have yours setup, but I will try to implement this later tonight and give you some screenshots if it works.

After taking many different attempts at the effect you’re looking for, I’m sorry to say I wasn’t able to get it to work correctly through blueprint.

To actually develop this, you would need a customized character controller with movement and gravity that take actor rotation into account before applying velocity. If I were to actually make something like this, it would be much easier to accomplish in C++ by modding the existing character movement code to retain all the other characteristics.

Unfortunately this would take more than a night’s work for me, so I won’t be tackling that challenge for you :frowning:

Hopefully in the future the engine will feature a vector variable for gravity direction exposed in blueprint, and a character controller that can rotate accordingly.

Thank you again for the help explaining it all. I had a sinking feeling that it could only be done with C++, for now. I feel like gravity will be much easier to manipulate in a future version, but for now I will have to work around this. I am thinking of making 1 mesh in 3ds max that makes up the whole level, but this is not an ideal way to deal with this because it adds a lot of extra work.

I want to thank you again for all of the time spent explaining everything to me, it has been really helpful and useful.

Hi Orangemicro,
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
Thank you.

I’m looking to be able to do the same thing, as I asked about here.

I’ve run into the problem of when I hit that 90degree mark, I can’t go any further, and working with blueprints, isn’t letting me change gravity to be able to work around that.

I’ve also worked with having the whole world rotate around, but that messes up anything that’s not static. So other objects move around when the world shifts.

I know however that this can be done, as shown in the following video, but I can’t seem to find out how it was done.