0 votes

I have a global "Man" object that I want to move between scenes. During the transition I do:

get_tree().set_pause(true) (play a pause-resistant transition animation) (load the new scene) Man.set_global_pos(position of entrance marker node in new scene) (play a pause-resistant return-transition animation) get_tree().set_pause(false)

After this unpause, for one frame Man acts like he's still in the pre-teleport position, triggering colliders and having unexpected ray-casts. I hacked around some of these side-effects by setting a "skip_frame_" boolean in Man_, and if that's true in _fixed_process, set it to false and return immediately. This resolved the unwanted interactions in Man's code, but unwanted colliders are still triggered by the outdated location. (And obviously I'd rather not have to inject this weird hack anyway.)

Is there some way to make the position of a KinematicBody2D fully update while the tree is paused?

This is with v2.1.3.stable.official

in Engine by (20 points)

1 Answer

0 votes
Best answer

Two possibilities:

  • Have you tried using 2.1.4? There were some bug fixes that may address your issue.

  • Have you checked "Motion Fix Enabled" in Project Settings > Physics 2d ? It's not enabled by default in 2.1.3 (it is the default for new projects in 2.1.4).

by (21,930 points)
selected by

Motion Fix Enabled fixed the weird direct interactions in Man's fixedprocess (the Man no longer thinks he's touching floor for one frame after he is teleported into the air). So thanks for that pointer.

The unexpected collision zone interaction still occurs though, triggering a BodyEnter(Man) sensor at the location the Man was in before the scene transition, even if I do Man.setglobalpos(Vector2(-99999, -99999)) immediately before loading the scene containing that sensor zone.

I think maybe the best solution for me here is to not retain the Man across scene transitions, and instead re-instance a new Man with saved attributes (storing those attributes in a global) after loading a new scene. That way there can't be any residual tainted physics attributes left over from the previous Man instance.

(This is with 2.1.4 now, that didn't fix the surprise collision detection.)

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.