Smoothly transitioning pawn collision cylinder height?

I’m trying to adjust the player’s collision cylinder when they start swimming.

I’m doing it like this when they enter water:



CylinderComponent.SetCylinderSize(CollisionRadiusSwimming, CollisionHeightSwimming);


The trouble is, once changed, it doesn’t affect the pawn’s location until they move. So when I exit the water (and increase the cylinder height back to normal), they player will briefly fall before it updates the pawn location, causing glitchy movement.

An easy way to see this is to just add an exec function that doubles the player collision height. Then use it in game, then walk forward. The player will fall before the correct pawn location is updated.

I would like to be able to smoothly interpolate the collision cylinder height and have the pawn’s location smoothly change.

Any ideas? Cheers

I guess I would set a boolean like bIncreaseHeight when coming out of the water. Then in the walking state tick event, if(bIncreaseHeight && VSizeSq(veloctiy) > 0) add some multiple of DeltaTime to the collision height, until the desired height is reached, at which point you set bIncreaseHeight to false.

Thanks for your thoughts @Nathaniel3W I’ll have a play around and see what I can get to work.