Change collisions of an Area2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By epord
:warning: Old Version Published before Godot 3 was released.

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.

:bust_in_silhouette: Reply From: eons

Maybe you hit something like this?

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.

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

epord | 2017-06-11 03:54