Collider floats when changing collision shapes

Godot Version

4.2.2

Question

I am currently recreating the physics from Sonic, and I am running into a problem when entering a roll. When starting the roll, I change the collision shape to fit in the smaller sprite. However, this leaves the collider floating for a few frames, enough for it to enter the air state. Here’s the code for changing the collision shape:

func HandlePlayerBounds(index: int):
	var collSize : Vector2
	var hitSize : Vector2
	var sensorScale : Vector2
	if index == 0:
		collSize = Vector2(19,39)
		hitSize = Vector2(16,36)
		sensorScale = Vector2(1,1)
	elif index == 1:
		collSize = Vector2(15,29)
		hitSize = Vector2(16,26)
		sensorScale = Vector2(0.75,0.79)
	collider.shape.set_size(collSize)
	hitbox.shape.set_size(hitSize)
	sensors.set_scale(sensorScale)

I know I need to update the collider’s position when entering a roll, but I am not sure how to do it. I tried changing the position with this code:

position += 4 * Vector2.from_angle(collider.rotation)

I’ve tried to run this both when the collider updates and the roll starts, but it doesn’t seem to affect the issue. Any help I can get is appreciated.