Tool Mode - Adding CollisionShape2D not working.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By avencherus
:warning: Old Version Published before Godot 3 was released.

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?

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

eons | 2017-12-20 23:44

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.

avencherus | 2017-12-21 04:00

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

eons | 2017-12-21 10:48

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

avencherus | 2017-12-21 19:24