+1 vote

Why doesn't disable the Collisionshape2d in code: "$CollisionShape2D.disabled=true". The collision shape is attached to a KinematicBody2. I did it exactly as shown in a tutorial, except that in tutorial Godot 3.0 was used.

asked Dec 16, 2019 in Projects by cristixxx (26 points)

3 Answers

0 votes

For some reason the following code doesnt work:

$CollisionShape2D.disabled = true

, however using the following works perfectly:

get_node("CollisionShape2D").disabled= true

you can also visualize the collisions from the Debug -> Visible Collision Shapes .. when it's disabled it turns to grey

I suggest you check in bugs list, and do a bug report if no one reported it earlier and not use $CollisionShape2D.disabled till it's solved

answered Dec 16, 2019 by Xtremezero (288 points)

Thank you for answer but it still doesn't work. It is strange that the collision shape does turn to grey but it is actually not disabled because can't pass through it.

hmm... very weird , do you mind uploading the project file to any storage cloud and share the link so I can check it in my side?

the link is private, cant open it

0 votes

I've encountered the same issue in Godot 3.1.2 and used layers as a workaround, but this seems to be fixed now in Godot 3.2 !

answered Jan 30 by Phil Rukin (14 points)
+1 vote

Try this:

$CollisionShape2D.set_deferred("disabled", true)

Which waits until it's "safe" to actually disable the collision shape.

answered Jan 30 by jgodfrey (1,655 points)

I had the same issue with my project and calling

$CollisionShape2D.set_deferred("disabled", true)

resolved my enabling/disabling collision shape issue. Thanks

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.