+1 vote

For example in a 2D game if my character walks behind a tree, I want that tree to become translucent. Prior to Godot 3.0, I believe you could set a CollisionShape2D and then click the trigger option, to see if an object entered a certain area, I don't know how to do this now.

in Engine by (32 points)

2 Answers

+3 votes
Best answer

Now you need to use Area2D and then inside CollisionShape2D nodes:

example project image showing Area2D nodes tree

After you do that you connect and use signals like areaentered or bodyentered:

example project image showing signals and script window

by (74 points)
selected by
0 votes

I found out the answer is to attach an AreaDetector2D to the object you want to react to the trigger object which enters the trigger area. You then attach a CollisionShapePolygon2D or a CollisionShape2D to the AreaDetector2D, and then click on the Node tab for the AreaDetector2D, click on body_entered and then click on connect a popup dialog will appear and then click on the original object for example if you named that object a "wall", then click connect. Godot will then create a listener function for you to write your code into for example you want to make the wall transparent or translucent or whatever you can do it here.

Basically it's explained well in this link https://www.youtube.com/watch?v=O5abE3aODxg&t=1s

by (32 points)
reshown by
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.