I can't seem to be able to enable my collisions2D via script.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AshesElite

So I’ve tried a bunch of methods that I can think of to try and enable my Collisions2D
which I have grouped together and attached a simple script to each.
I call a function in that script which I assume works due to a print test (“walking in the air”)
yet still no luck. I know I’m probably just being dumb, but it’s driving me crazy… :frowning:

extends CollisionShape2D

func walk_on_clouds():
print(“walking in the air”)
var cloud = is_disabled()
cloud = false
#disabled = false
#set_deferred(“disabled”, false)

NOTE: the other two methods I tried I kept them commented to show here.

:bust_in_silhouette: Reply From: jgodfrey

Assuming the above script is attached directly to the CollisionShape2D you’re trying to enable, then this should work:

set_deferred("disabled", false)

If that’s not working, then something else is wrong. In that case, maybe show us a screen shot of your scene tree, with the CollisionShape2D selected, and the above script shown in the script editor…

Sorry I’ve since changed method by making my clouds a layer of their own.
It has fixed my issue. :slight_smile: Thank you for taking the time to reply :slight_smile:

AshesElite | 2020-03-09 20:11