- Edited
How can I detect a collision with a Polygon2D? I'm trying to make music fade in/out at certain regions of the game, so there will be a bunch of Polygon2Ds that designate the areas each track will play at.
I'm currently just checking each _process call for each polygon if the player is inside it with Geometry2D.is_pont_in_polygon(player.position, poly.polygon)
.
This is probably gonna be terrible for performance later on, but it's also kinda crappy to work with, because it completely disregards scale and position of the Polygon2D objects by getting the polygon points directly. This means I have to always make sure their positions and scales are 0,0 and 1,1, and manually move the actual points in the polygon to the right place. Sure, I could take poly.polygon
and do some math to apply the polygon's position and scale on the points, but that would make performance even worse.
Just looking for simple collision detection between the player and the Polygon2Ds, accounting for position and scale as well. How can I do this?