Godot Version
4.2.1
Question
I was making platforms that would crumble when the player hit them. I quickly coded something simple that works. I was thinking of ways to add several of the platforms with their own shapes. I decided to use metadata. I’ve never worked with metadata before this, but it seemed straightforward. I coded it up and it works fine when there’s only 1 platform, but if you add another one and set the metadata, for some reason the ColorRect that I’m using as a placeholder is sized correctly, but the hitbox stays the same size depending on what the first platform’s perimeters are. Here’s my code:
var size = get_meta("perimeter") / 2
tile_texture.size = size * 2
tile_texture.position = size * -1
# This is where the hitboxes sizes are being set and what isn't working.
tile_collision_shape.shape.extents = size
tile_collision_area_shape.shape.extents = size
The perimeter is a Vector2D that defines the shape of the platform. So basically, the hitbox shape of the other platforms are being set to the metadata of the last instance of the tile. For example:
Tile 1 perimeter: (200,100)
Tile 2 perimeter: (100,100)
Tile 1’s hitbox is set to the size of tile 2’s, but for some reason, the ColorRects I’m using to show the platforms are correct. I don’t know if this is an issue with the metadata or the CollisionShapes.