+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.

asked Jan 15 in Engine by dragon (29 points)

2 Answers

+3 votes
Best answer

Now you need to use Area2D and then inside CollisionShape2D nodes:
https://docs.godotengine.org/en/3.1/classes/class_area2d.html

example project image showing Area2D nodes tree

After you do that you connect and use signals like areaentered or bodyentered:
https://docs.godotengine.org/en/3.1/getting_started/step_by_step/signals.html

example project image showing signals and script window

answered Jan 15 by oofman (72 points)
selected Jan 15 by dragon
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

answered Jan 15 by dragon (29 points)
reshown Jan 15 by dragon
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.