+2 votes

I have a animationplayer node that swaps the collisionshape2D animations, but I don't want the collision shape to be active while the animations are not playing.

I was wondering if there was a way to disable the collision detection in CollisionShape2D. When I mean collision detection I don't mean it as a trigger like set_trigger(false) that can still be set off. I mean to turn it off completely, and have it enabled again when desired. so queue_free() is also out of the question.

in Engine by (273 points)

1 Answer

+1 vote

Like removing all the layers and/or masks?

Areas can just set off monitoring and monitored status or turn off both layer and masks, the current behavior is kind of buggy (they seem to look for layers and masks instead of masks only, and react when not monitoring but are monitored).


Btw, I'm talking about the CollisionObject here (the parent), not the CollisionShape node because it is just a helper that uses the same shape resource as the parent.

by (7,946 points)

If setting it to a different layer/mask will stop it from interacting with all objects/other collisionshapes, but keep it's animations intact, then yes. Tell me how to send it to a different layer/mask.

By the way I'm using Godot 2.1.3

Basically, layers are where the bodies are (detected) and mask where they look for other bodies.

On script, PhysicBodies and Areas have layer_mask methods for layers and collision_mask methods for masks (confusing names).
http://docs.godotengine.org/en/stable/classes/class_physicsbody2d.html#class-physicsbody2d-set-collision-mask

The "bit" ones refer to the checkboxes you see on the inspector, the other uses an int but as binary (because is easier to operate multiple flags with bitwise operations).

TileMap have this too.

And Areas also have monitoring status:
http://docs.godotengine.org/en/stable/classes/class_area2d.html#class-area2d-is-monitorable

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.