Freezing Y position when using rootmotion

Hi, I’m making a combat system for a hack and slah game (imagine Devil May Cry), I am using rootmotion for the attack animation because I want the movement during attacks to look natural.
The problem is that when the animation plays the character gets lifted off the ground. I have looked at other answers about this problem but most of them just say to turn off root motion.
Is there a way to freeze the Y position of an animation while still using root motion?
Any help would be greatly appreciated.

it’s possible to avoid y movement from the animation itself.it’s called bake into pose and can be configured from the animation inspector: