How can I disable a collision shape associated with a Sprite ?

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

Hello ,
I have a node StaticBody2D >> Sprite>>CollisionShape2D
now i HAVE A script which randomly changes the texture associated with the sprite.
NOw say the sprite has texture ‘a’ , n when it changes its texture from ‘a’ to ‘b’
the collision shape should be disable and the objects (players) standing on the sprite should fall down

Any Help WIll be Highly Appreciated !

:bust_in_silhouette: Reply From: Godot Petrópolis

Hello!

I’m sorry my English and the fact that I’m a complete noob in the programming world and in the Godot Engine, but . . .

Some days ago I try some thing similar.

In my case I use this:

get_node ( "CollisionShape2D" ).set_trigger ( true )

true – the collision shape is deactivated

false – the collision shape is activated

It’s not working…

Arindam | 2018-07-22 18:18

? it’s worked for me

thank you everyone :slight_smile: !

edit:
oops , sorry, im using another code, it was like this :

get_node(“CollisionShape2D”).disabled = true

and if we want to return it back ,use:
get_node(“CollisionShape2D”).disabled = false

—this is in Godot version 3—

ruruarchy | 2018-12-13 11:47