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.

asked May 26 in Engine by jtumain (22 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.

answered May 26 by jtumain (22 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 How to use this Q&A? before posting your first questions.