Handling movement and change of gravity

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By XavierGerD

Hi,

I’m currently trying to make a game where the player can jump from a platform to another platform that has a different orientation. When the player reaches the second platform, gravity changes and the player is pulled towards that platform. The camera rotates to match the new center of gravity.

Where I’m having trouble is making sure the player is able to continue walking on the new platform after the jump. For some reason, even though the whole Player node is rotated, the controls are kept aligned with the old platform, e.g. A and D, which were formerly used to go left and right, now go up and down, etc.

I don’t have much in the way of code right now to demonstrate this. I have this bit, which changes the orientation:

var newRotation = currentPath.get_parent().rotation    
if not self.get_parent().rotation == newRotation:
			self.get_parent().rotation = self.get_parent().rotation.linear_interpolate(newRotation,  4 * delta)
	

And this, which is how movement is handled:

if Input.is_action_pressed("MoveForward"):
	Direction -= transform.basis.z
elif Input.is_action_pressed("MoveBack"):
	Direction += transform.basis.z
if Input.is_action_pressed("StrafeLeft"):
	Direction -= transform.basis.x
elif Input.is_action_pressed("StrafeRight"):
	Direction += transform.basis.x

Direction = Direction.normalized()
Velocity = Velocity.linear_interpolate(
	Direction * Constants.Speed,
	Constants.Acceleration * delta
)
move_and_slide(Velocity, up)

Any help would be greatly appreciated!!