There is a way to get your speed back, not to define it, but it will work only if when you exit for ex. water to new surface that 100% identical to one from which you got into the water.
Something like "if got in water set private variable "oldspeed" to speed, then change speed and if not in water set speed to "oldspeed""
But it's a crap