0 votes

Hi, I am trying to make water on Godot. For that, I have an Area2D with a CollisionShape2D to detect what bodies are entering the area. Since it's water, I want the shape of that CollisionShape2D to change, so I tried to use a ConvexPolygoneShape2D in the CollisionShape2D and change its points and I also tried to use a CollisionPolygon2D instead of the CollisionShape2D. But everytime the Area2D used the first collisions, it doesn't matter if I change or erase them, the area will always use its first collisions.

Is there a way to change the collision of an Area2D in the middle of the game?

Maybe the Area2D sticks to its initial collisions and there is another tool to check bodies entering a certain area with changing shape.

in Engine by (21 points)

1 Answer

0 votes
Best answer

Maybe you hit something like this?
https://github.com/godotengine/godot/issues/8325

Areas are not made to have shapes constantly modified but there are many ways to solve it, you can use many shapes and move/add them and I have found that doing set_pos after changing the shape updates the detection zone, but I don't know the cost of doing that.

Another option is to use the Shape2D API or the Physics2DDirectSpaceState and do the overlap checks yourself.

by (7,946 points)
selected by

Thanks for your answer! I will have this in consideration.

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.