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

bug with collisions shapes in saved scenes #7253

Closed
curly-brace opened this issue Dec 6, 2016 · 1 comment
Closed

bug with collisions shapes in saved scenes #7253

curly-brace opened this issue Dec 6, 2016 · 1 comment
Labels

Comments

@curly-brace
Copy link

  • create saved scene with staticbody2d as root
  • add it to game scene
  • add collisionshape to it
  • rigidbody2d will fall through it

it will only work if collisionshape not only added inside savedscene, but also configured (shape created) in its hyerarchy and not in game scene hyerarchy.

and if you move such (with enabled editable children) collisionshape (part of saved scene) somewhere down (for example putting it after an added sprite node (inside game scene i mean)), there would appear two collisionshapes, one read and one white, but you couldn't delete ant of them anymore.

i was trying to create a general staticbody2d with script, that would represent different types of platforms, depending on settings i setup in exported script options. the only things i planned to edit manually - adding sprite nodes and collisionshape (one) as children of that instanced saved scene, but now it is impossible to implement.

godot 2.2 latest.

@bojidar-bg
Copy link
Contributor

Duplicate of #2314
Workaround from @bojidar-bg there:

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)

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

No branches or pull requests

2 participants