-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Physic Body Instanced scene doesn't use CollisionShapes #2314
Comments
This problem is due to how godot handles collision shapes. |
That still doesn't solve the issue. The collision shape should be process and added to the parent. |
In 2.0 Alpha there is quite elegant and simple workaround, a script that we can be added to collision shape:
|
This issue persists with new instancing system (422929e). |
will not be fixed until 3.0 because it needs compatibility breakage for it to be made to work properly :( |
@reduz can't it be fixed just by adding check in "ready" equivalent of c++ core code of CollisionSphere?
|
As noted in #4348, this concerns all CollisionObjects, not just PhysicsBodies |
Ahah, finally was able to workaround this in a game of mine: extends CollisionObject2D
func _ready():
for shape in get_children():
if shape.has_meta("__registered") and shape.get_meta("__registered"):
continue
get_tree().set_editor_hint(true)
remove_child(shape) # Make it pick up the editor hint
add_child(shape)
get_tree().set_editor_hint(false) # Unset quickly
if shape extends CollisionShape2D: # Now update parent is working, so just change the shape
shape.set_shape(shape.get_shape())
elif shape extends CollisionPolygon2D:
shape.set_polygon(shape.get_polygon())
remove_child(shape) # Reset its editor hint cache, just in case it was needed.. (you might drop this part if it bottlenecks)
add_child(shape)
shape.set_meta("__registered", true) |
Well, this is really heavy hack I'd say... I think it is better to patch On Sat, Nov 19, 2016 at 6:12 PM, Bojidar Marinov notifications@github.com
|
@slapin You think its heavy? No, it's relatively lightweight, but it would all be better if there aren't hacks for this. |
I would like to report that this is also happening with vehicle wheels so this is likely an issue for more than just collision shapes |
I believe I am encountering this with an instanced Area2D, where the Area2D is defined in a parent scene, and the CollisionShape2D is defined in a scene which derives from the parent scene. I've created a sample project that reproduces the issue. I'm using Godot 2.1. I also believe this is the cause of https://godotengine.org/qa/3156/collision-callbacks-dont-fire-on-embedded-area2d-class. |
Just got bitten by this bug too, thanks @bojidar-bg for the workaround, though it only works for a single shape. When multiple shapes are defined, only the first is detected. Any idea why? |
@xphere Sounds strange, though you should probably try to tweak the workaround yourself -- AFAIR it might not always work with CollisionShape2D nodes (unlike CollisionPolygon2D nodes) |
Thanks, @bojidar-bg For some reason, when dealing with multiple shapes, the workaround fails to add the last one. I hope this will be fixed in core so we don't need ugly workarounds. |
I think this should be fixed now. Can you recheck? |
this is definitely fixed now, so closing |
When instancing a PhysicBody2D node (don't know if this is true for 3d as well) the new CollisionShape or CollisionPolygon nodes added as childs of the instanced scene are not used for the collisions.
This is the hierachy:
I think this is useful in a lot of ways, but it also follows the whole idea of "instanced scenes". Besides if it works with other nodes, why not with collision shapes?
Here's a test project: https://dl.dropboxusercontent.com/u/274954519/instance_scene_collision_test.zip
The text was updated successfully, but these errors were encountered: