Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision shape extents, radius don't get reset when get_tree().reload_current_scene() is called #42400

Open
kneghtmare opened this issue Sep 29, 2020 · 4 comments

Comments

@kneghtmare
Copy link

kneghtmare commented Sep 29, 2020

Note: I apologize for any issues with the format of my writing. This is my first time using GitHub and reporting a bug

Godot version:
Godot v3.2.3-stable-win64

OS/device including version:
Intel i3 with integrated graphics. Windows 10

Issue description:
Restarting a scene by using get_tree().reload_current_scene() or get_tree(),change_scene("current scene name") doesn't reset collision shape extents or radius that have changed during runtime of the game. Ideally, when a scene is restarted, all the radius and extents should be reset to the radius and extents in that have been configured in the editor.

Steps to reproduce:

  1. Make a simple scene with only a StaticBody2D and give it a CollisionShape2D of circle shape
  2. Reduce the radius of the collision shape every few seconds in code
  3. Print the radius of the shape onto the screen
  4. Make the scene restart after some time, maybe 10 seconds and when the scene restarts, the collision shape radius doesn't get reset as well

Minimal reproduction project:

Collision shape issue.zip

@Calinou
Copy link
Member

Calinou commented Sep 29, 2020

While quirky, I'm not sure if this is actually a bug. Since collision shapes are resources stored inside nodes, they're not technically part of the current scene.

As a workaround, enable the Local To Scene property on the CollisionShape resources. You can do so by clicking them in the inspector then scrolling down to the Resource section.

@kneghtmare
Copy link
Author

kneghtmare commented Sep 29, 2020

While quirky, I'm not sure if this is actually a bug. Since collision shapes are resources stored inside nodes, they're not technically part of the current scene.

As a workaround, enable the Local To Scene property on the CollisionShape resources. You can do so by clicking them in the inspector then scrolling down to the Resource section.

Hmm, that makes sense but this is kinda unexpected behavior, a lot of beginners could get stuck on this. I personally was stuck on this for a few hours before finding out what the issue was and just set the collision shape radius on ready in code. If that is the only thing that the Local To Scene property does, it should be enabled on default in my opinion.

@Calinou
Copy link
Member

Calinou commented Sep 29, 2020

If that is the only thing that the Local To Scene property does, it should be enabled on default in my opinion.

Unfortunately, making every resource unique by default would decrease performance and increase memory usage.

@Hozerino
Copy link

Hozerino commented May 5, 2022

I know this issue is old and stuff, but I've had the same exact problem on Godot 3.4.4 (mono/C# edition). The Shape size isn't being resized back even if I run the "reload current scene" method. So it still persists and it saddens me to know that the only fix is not scalable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants