ScalableCollisionShape.gd 380 B

1234567891011121314151617
  1. @tool
  2. extends CollisionShape2D
  3. @export var offset := Vector2.ZERO
  4. @export var link: Node2D
  5. func _ready() -> void:
  6. set_process(Engine.is_editor_hint())
  7. func _process(_delta: float) -> void:
  8. update()
  9. func update() -> void:
  10. var height_to_use = shape.size.y
  11. if link != null:
  12. height_to_use *= link.scale.y * link.scale.y
  13. position.y = -height_to_use / 2 * scale.y - offset.y