0 votes

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

in Engine by (527 points)

2 Answers

0 votes
Best answer

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!

by (527 points)
0 votes

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
by (10,221 points)
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 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 webmaster@godotengine.org with your username.