This is incorrect. There is no property called set_disabled
, so this will produce an error.
You can either do
$CollisionShape2D.disabled = true
or call the setter
$CollisionShape2D.set_disabled(true)
Although the former is standard practice; properties are directly accessible.
It may be you're confused by the need to use set_deferred()
when a property of a physics object needs to be changed during the physics processing step. Since that's not allowed, the change must be deferred to the end of physics processing.
set_deferred
takes two arguments: the property name, and the new value:
$CollisionShape2D.set_deferred("disabled", true)