Letting objects be pickable without being collidable

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

I have some objects and I use a raycast to be able to pick them up. However, for many of them I’d like to be able to walk through them while still being able to pick them, such as plants. How would I do this? Changing the collision layers and masks didn’t seem to do what I needed, it just disabled the collision altogether

:bust_in_silhouette: Reply From: njamster

I never tried this in 3D, but I suspect it works the same as for 2D.

Use an Area3D, attach it to the player and either…

  • … connect the body_entered-signal to a callback, that automatically picks up the the entering body if it is a pickable object (use groups!)
  • … or check for overlapping bodies when the player provides a certain input and pick up any overlapping body that is a pickable object
:bust_in_silhouette: Reply From: andersmmg

Okay, I figured it out. I just put the object in the second layer and added that to the interaction raycast mask. Worked like a charm, and didn’t require weird hacks!