How to "fill" a CollisionShape2D with a sprite pattern ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Asthalis

Hello everyone,

I am building a platformer 2D and I want to add fans to my levels to push the hero when he gets close to them. Each fan is a RigidBody2D and I want to use an Area2D to set the zone where the wind blows (modified gravity).

Do you know is there is a way to “fill” the Area2D’s CollisionShape2D (a rectangle in my example) with a sprite pattern ? I’d like to use an animated sprite to show the direction of the wind in the whole zone and all Area2Ds may have different sizes.

Thanks a lot

:bust_in_silhouette: Reply From: kidscancode

Collision shapes are not visible, so you can’t do this directly. However, if you want to display an image tiled in a polygon, you can use a Polygon2D:

Thanks a lot for your answer, I will try this way. I have not used polygon2D so far so I guess this will be a nice opportunity to have a look at them.

By the way, my projet is going on, almost 40 levels so far and I hope to reach 100 of them when the game is complete !

Thanks again and before I forget, your tutorials are pure gold to me.

Asthalis | 2020-10-14 15:40