Posted July 18, 2025 by Wandering Door Games
#Godot
Scaling physics driven entities is a bit tricky. All our little guys have a collider on them since we want them to be able to interact with the world around them and bash into enemies.
You shouldn't scale these colliders as it could result in physics issues.
Normally, the way you make the collision shape match your sprite is to resize the actual shape itself. But no one wants to do that manually. We want dynamically scaled spaceships!
So we have to do this with code. Our sprites are setup in scene with their scale at 1.0 x 1.0. This means we can simply multiply the new scale value by the collision shape's values. In our case, we have a capsule shape, so we'll be dealing with radius and height.
A quick caveat is that if your collider isn't centered at (0,0), you'll want to apply that scale to its position, too.
Here's a code snippet of this concept:
Note that we had to duplicate and swap out the collision shape to make it unique, otherwise as each ship spawned in they would update the colliders for all of the other ships!
For our purposes, you can see in the snippet that we had to scale the particles too. If we didn't, we'd have tiny spaceships with giant flame trails, which isn't ideal.
You can see the full project up on Codeberg here.
--
Love open source projects? Here are ways you can support us making them!