The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hi everyone,

Short Version
How do you set the position of a KinematicBody2D without effecting its velocity?

Long Version
I'm making a 2D game that has gravitational elements, so occasionally the player maybe upside down. I have set up portals that the user can teleport between using NodePaths, assigning the target node on a portal to another portal and getting the target node's position to set the players position using:
global_position = get_node(teleport_target).position

The player moves to the correct position, however if the player goes in the portal upside down in the air (i.e. is going upwards as if they're being pulled to the ceiling); when they come out the other, the velocity does not stay the same and they get pulled downwards as if gravity has returned to normal.

One thing to note, is that after teleporting the move_and_slide call in my physics_process, is_on_wall() is "true" for some reason.

Is there something that I'm missing or need to know to fix this issue.

Thanks for any help in advance.

in Engine by (26 points)

1 Answer

+1 vote

Sorry, the issue was my own misunderstanding.

I use a visibilityNotifier2d to detect when the player is out of the camera bounds to kill them. This was happening when the player teleported, meaning the game was reset, so everything is working as intended.

by (26 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.