Files
Super-Mario-Bros.-Remastere…/Scripts/Classes/Components/ScalableCollisionPolygon.gd
KirbyKidJ e6bc64affb Refactored Small Crouching and Big Crouching
- Added new variables to `CharacterInfo.json`
- Made it so `BlockCollision` area position is attached to top of `SmallCollision` and `BigCollision`
2025-10-09 15:16:14 -07:00

19 lines
452 B
GDScript

@tool
extends CollisionPolygon2D
@export var offset := Vector2.ZERO
@export var height := 0.0
@export var hitbox := Vector3.ONE
var crouching := false
func _physics_process(_delta: float) -> void:
scale = Vector2(hitbox.x, hitbox.y)
if crouching and get_meta("scalable", true): scale.y *= hitbox.z
update()
func update() -> void:
var height_to_use = height
if get_meta("scalable", true):
position.y = -height_to_use / 2 * scale.y - offset.y