0 votes

Not sure if this is a bug, but I have a tool script that will clear some RigidBody2D nodes, and recreate them with CollisionShape2D nodes.

However, they don't actually work when the game runs. If I right click on them and choose "Make Unique", they start working fine.

Anyone have a clue on what is causing this behavior? Is there some trick or way around this?

in Engine by (5,242 points)

Godot 2?
If is 2 then the shapes, if added at runtime, need to be manually added to the body too (set_shape).

Oh yeah, it probably is time to start mentioning the version. X)

It is in 2.

The problem lingers in the editor side of things. Generally, haven't had this problem with other things, so it makes me think maybe there is some kind of timing issue with how things are being created and entering the scene. Haven't been able to tease anything out.

The shape in the CollisionShape2D initially would say something like "CapsuleShape2D", then when the scene saves, its name changes to the scene's name, and will not generate any shapes when the game runs. Not until I go through them and click Make Unique. That seems to fix them, yet I'm making this tool to save time since there will be hundreds of these things.

But I think I've lost enough time on it, that I'm just going to write _draw() code to show the potential shapes in the editor, and then use add_shape() at runtime.

You can still use CollisionShape nodes to get debug information on runtime, just add the same shape as the parent body to it.

Thought about that, but decided against it. Since I don't know what the issue is I don't trust them. X)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.