Godot Version
Godot 4.3
Question
I have a series of wall prefabs that contain a root node, a sprite, and a collisionpolygon2d. These wall prefabs are the children of a Node2D that I call the anchor. I am changing the skew of the anchor by changing its basis vectors, i.e. setting its transform.x and transform.y directly. Visually this causes the whole level to distort in a way I want, but for some reason the collisionpolygon2D hitboxes don’t seem to actually update, and my CharacterBody2D moves around and collides with the original wall positions. Is there a reason that the hitboxes can’t handle skew? Or is there a way to force them to update after I change the skew?
The odd thing is that when I change the skew in the editor and then start the game, the hitboxes reflect the skew as it was set when the game started. So there must be some way to make the update happen in code, right? But no matter what I try, it doesn’t work. I have tried the following code:
var shape = $CollisionPolygon2D.polygon
$CollisionPolygon2D.polygon = shape
$CollisionPolygon2D.force_update_transform()
to see if that updates it, but to no avail. I also tried deleting and recreating the CollisionPolygon2D nodes in all the walls, but that didn’t work either. Any ideas? Thanks in advance!
Code to adjust the skew:
What the level looks like at the start of runtime:
What the level looks like after adjusting the skew:
Node structure for the level: