how to get collide mask id ? make collide have different effect?

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

i use KinematicBody2D
how to get mask id
example when i collide with mask 1(player) = queue_free(), mask 3(stone) = stop move, mask 5(item) = change color

if i code like this

if move_and_collide(velocity*delta):

it will apply to all mask… so how to make it apply to only one mask
enter image description here

:bust_in_silhouette: Reply From: njamster

You can do:


This will return true if the first bit of the layer/mask is set or false otherwise. To get the second bit instead, just pass 1 instead of 0 as an argument. And so on.