As you might be able to tell from this code, I am brand-new to Godot and am creating my first project to learn the engine. I am trying to make the ability to pause time in game with the built-in pause feature in Godot. I have the player able to move and platform when in this paused state, however whenever I step on a platform while the game is paused, the player slides in the direction that the platform would be moving. This may be a very easily solution, but I'm new to the program and don't necessarily understand how to work if/else statements. When looking at the code, I believe that the move and slide feature is the reason why this is happening. Could I get some help here?

Welcome to the forums @TheRealLSWC!

The issue is on the second script, correct? If so, it’s because you have = in a condition, which is assigning rather than comparing. To do a comparison, you want to use ==.

Though the code in the second screen shot won’t work quite right even after that is fixed, because your condition is checking to see if paused is not equal to paused, which will never occur and therefore never execute. If you are wanting to check to make sure the player is NOT paused, then you want to do something like this instead:

# if the game is NOT paused...
if get_tree.paused == false:
	_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y

Alright, I see what you mean. Thanks for that clarification!

...I should clarify that I am putting this script on a separate object that is a moving platform, separate from the player, and part of the level. This platform should be pausing whenever the pause event is started, and it does, as it's 'pause mode' property in the inspector is set to inherit. The problem is, however, that when the player jumps on the platform when the platform is in the pause state (and the player's 'pause mode' property is set at process), the player will slide in the direction that the platform would be going if the game wasn't paused (even though the platform itself isn't). Could this be a problem in the player's script instead?

Here's a link to each one of the scripts that may be contributing to the problem:

Player Script: Moving Platform Script: Pause Menu Script:

Thanks so much for your help, and for how quickly you answered. I really appreciate it!

Ah okay, that makes sense. I would guess that the issue is probably more likely to be in the player script that the moving platform, though it is equally possible that pausing makes the physics state pause, so the moving platform is also contributing. KinematicBody2D turns movement into velocity, so its possible that it is pushing the KinematicBody on top of it.

In the moving platform script on line 10, you need to add () to the end of get_tree because it's a function. That will remove the error in the script and may also fix the sliding issue. If not, then it is almost certainly the player or something else causing the issue.

Oh, right haha. That didn't do it, so I think it's a problem with the KinematicBody2D. However, I think I'll just take an alternative approach to the game, and make it so the moving platforms are springs, and you are propelled in the air when landing on them. That should get rid of the sliding problem.

Thanks for all your help, I really appreciate it!

a year later