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 shapes persist after they've been deleted #7693

Closed
xyroclast opened this issue Feb 1, 2017 · 16 comments
Closed

Collision shapes persist after they've been deleted #7693

xyroclast opened this issue Feb 1, 2017 · 16 comments

Comments

@xyroclast
Copy link

xyroclast commented Feb 1, 2017

OS: Linux Mint 18
Godot: 2.1.2

Steps to reproduce:
Create a scene consisting of a KinematicBody with a child CollisionShape (I used capsule). Add some sort of image or animation as well, so the object is visible (I used AnimatedSprite3D). Script the KinematicBody so that it has downward movement (I used the move() function with a downward Y direction)
Save the scene and place an instance of the scene in a scene with a collide-able floor.
Test the game and verify that the object stops at the floor.
Then, delete the CollisionShape from the saved scene.
When you run the test again, you should see the object still continuing to collide with the ground.

Originally I thought this was just my lack of understanding of how Godot collision works, but you can verify that it's a bug by following the above steps again, but never create the CollisionShape in the first place. The object will pass through the floor as expected.

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

I think the scene is not being updated on the main scene if you run it just after deleting the node, if you touch anything on the main scene so it gets marked as modified before running, it should update the instance with the current version.

@xyroclast
Copy link
Author

Doesn't seem to be the case in my project, unfortunately, as far as I can tell - I've modified quite a few things in the main scene over the last while and haven't had any of the removed collision shapes stop doing their thing.

As an added note, not sure if it's causing the issue, but when I looked into one of the afflicted sub-scene files in a text editor, I noticed that it still has a reference to the deleted capsule - "[sub_resource type="CapsuleShape" id=1]" - Is it possible that the CollisionShape object is being destroyed, but somehow the associated shape itself is somehow staying behind and causing trouble?

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

Is possible that, for some reason, the collision shape node was removed and the shape resoure remained there.

I was unable o replicate, at least on Windows, I see the CollisionShape2D (after deleting the original) on the editor but does not appears (nor the shape) on the running scene.

@bojidar-bg
Copy link
Contributor

Duplicate of #2804.

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

@bojidar-bg I don't think is duplicate because if I understand right, is removing the shape from the editor, not the common error of removing shape from code.

@bojidar-bg
Copy link
Contributor

@eon-s Yeah, but the cause is still the same, even if the symptom is different. You don't get to go to your doctor for coughing and running nose separately, you go for both at once.

Anyway, thinking about it, I guess I might reopen this one, since it should be easy to fix this symptom in core.

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

@xyroclast I can't replicate on Ubuntu 64 bit either, maybe your project/scene was corrupted, using different Godot versions perhaps?

Check if you can do it on a new project and share the broken scenes.
Also, just in case, try with the self contained mode (an empty ._sc_ file where Godot executable is located).

EDIT: see below

@bojidar-bg I thought it could be some problem with resources on the scene file in 2.1.2 but can't break my scenes here, not even in my most messy projects, might be something else.

@pkowal1982
Copy link
Contributor

I've also encountered this problem. On Windows 7 and Ubuntu 16.04, both 64 bits versions. Godot 2.1.2 and before.
Short example to check it on your own.
It should print COLLISION on run without modification.
But get rid of RemoveMe node and run the scene once again. For me it still prints COLLISION.
godot_remove_bug.zip

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

For some reason, I was trying to do this on 2D, maybe got confused reading something else, that is why example projects are more than welcome I guess 😅


And yes, removing the CollisionShape for any kind of body does not remove the shape resource, even on Godot 3, custom build of 01/30 from fixnum.org site.

@reduz
Copy link
Member

reduz commented Feb 1, 2017 via email

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

To avoid this problem while we wait for Godot 3, before removing a CollisionShape, clear the Shape from the inspector, that should remove it from the scene file.

@xyroclast
Copy link
Author

Thanks for the responses guys, I'll go with @eon-s 's fix until 3 comes out!
I'm proud that my understanding of Godot has grown enough that my bug senses were tingling correctly.
One more question: What's the easiest way to fix scenes where I've already deleted the shape, without breaking things? Is it best to tear each one down and start over, or is there a reasonably simple fix? (my thoughts jump to finding lines to delete from the scene files in a text editor, but that might be unadviseable?)

@eon-s
Copy link
Contributor

eon-s commented Feb 1, 2017

@xyroclast Adding a new collision shape, setting shape then clearing it may solve the inconsistency on the scene file.

Or, to make it by hand or if you have more shapes on the body, with the scene closed on Godot, open the tscn file with a text editor, on the section where the body data is located there should appear a couple of "shapes" references (type and properties), check the id and remove the resource with that id on the top of the file, then delete all these lines on the body part (if there are many shapes I'm not sure if you have to fix the index there), finally put the shape count on zero (or the corresponding number) for the body.

@xyroclast
Copy link
Author

@eon-s thank you!

@xyroclast
Copy link
Author

Update for anyone else needing a fix:
I've just verified that adding a new CollisionShape node to the KinematicBody will immediately erase the persisting shape object.

@kubecz3k
Copy link
Contributor

kubecz3k commented Apr 10, 2018

I'm revisiting old issues, I think this should be fixed in 3.0, please let us know if that's not the case!

@kubecz3k kubecz3k added this to the 3.0 milestone Apr 10, 2018
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

6 participants