Shifting Gravity - Mouselook problem

Hi everyone :cool:,

I recently started working on a FPS with shifting gravity (I’m basically trying to obtain something like this :, where you can walk on nearly every wall). After a lot of research and scripting, I finally managed to end up with what I wanted, but there are still some things to improve. I just recently added the mouselook script, but there are some problems when the gravity shifts.

A quick presentation of the game :

As you can see in the picture, the gravity is normal at the beginning (z- axis). When the player walks to the wall on the left, the gravity switches to the x- axis, and the wall becomes the floor. If the player goes forward again, the gravity switches to the z+ axis, and he ends up upside down.

The movement script works fine with the gravity switching : for example, in the “x- zone”, the W key still makes the player go forward (only it’s along the z axis, not the x axis like in the “z- zone”). This is because the player rotates so that his feet (well, it’s more of an octagonal base here) always face downwards in comparison with the gravity.

My problem is that it doesn’t seem to work the same with the mouselook script : when I move the mouse in the “x- zone”, the camera rotates along the global y and z axis, so I can’t look to the left or the right, and when I enter the “z+ zone”, the controls are inverted along the global z axis (moving the mouse left makes the camera rotate right).
I tried to look at the script but it is quite complicated and I couldn’t locate the problem, so I hope someone out there has an answer :smiley: (I’ve been using this mouselook script :

And if anyone knows how to do stairs that I can climb like in the first picture, it would also help me a lot. I tried to create a 45° angled plane but the player keeps sliding down because of the gravity, so I guess it has something to do with friction.

Any kind of help is appreciated


ok, your mouse look needs to use local rather than global

we dealt with same issue in Wrectified LVL 1’s space ship,


NormalGravityWMouse.blend (1.37 MB)

Wow, didn’t expect such a quick reply :slight_smile:
The script you gave me works perfectly, thanks

Any ideas how to deal with the stairs problem ?

turn off gravity? use “Normal Gravity” and have a collision plane that goes up stairs? and the visual stairs no collision?

But then the player would stand at a 45° angle, wouldn’t he ? I want the player’s feet to be parallel to the floor that leads to the stairs (basically, using only the 6 global directions as vectors for gravity, x, y and z and x-, y- and z-)

Our script aligns to face normals and applies gravity that way, but that does not mean your player needs to be the physics object,
you could have the player parent to the physics object, but have it’s own alignment, that changes at mid stair point? you could use the face material, or a property retrieved by the ray to set the player angle for each surface

like 1/2 the stairs are in 1 gravity frame, and the other half are in the other? have a “transition” angle change?