Undertale battle arena Resizing - How?

Godot Version

4.5

Question

So im trying to make a Undertale fangame in godot, and i want the box where the Soul (Heart) is trapped in to be resizable by simply writing like the width and the height, but i have no idea where to start with. Any help?

Define the box using a Rect2.
After you move the heart, clamp its position coordinates to range rect.position and rect.end

how do i do this? maybe an example would be nice

var rect = Rect2(100.0, 100.0, 320.0, 200.0)
global_position = global_position.clamp(rect.position, rect.end)
1 Like

In case you’re wondering about how to render the box, you can use a NinePatchRect