Steps to Reproduce:
Swim towards a corner, with a block above you.
Stop moving.
Observed Results:
The player's arms and legs keep moving.
Expected Results:
The swimming animation pauses, and continues when you start moving again.
Screenshots/Videos attached: No
Notes: This can be fixed by changing the animation from this...
"animation.player.swim" : {
"animation_length" : 1.3,
"loop" : true,
"override_previous_animation" : true,
"bones" : {
"leftarm" : {
"rotation" : {
"0" : [ 0.0, 180.0, 180.0 ],
"0.7" : [ 0.0, 180.0, 287.2 ],
"1.1" : [ 90.0, 180.0, 180.0 ],
"1.3" : [ 0.0, 180.0, 180.0 ]
}
},
"rightarm" : {
"rotation" : {
"0" : [ 0.0, 180.0, -180.0 ],
"0.7" : [ 0.0, 180.0, -287.2 ],
"1.1" : [ 90.0, 180.0, -180.0 ],
"1.3" : [ 0.0, 180.0, -180.0 ]
}
},
"root" : {
"position" : [ 0.0, "(math.sin(query.target_x_rotation) * 24.0 + 3.0) * variable.swim_amount", "(math.cos(query.target_x_rotation) * 24.0 + 9.0) * variable.swim_amount" ],
"rotation" : [ "variable.swim_amount * (90 + query.target_x_rotation)", 0.0, 0.0 ]
}
}
},
"animation.player.swim.legs" : {
"loop" : true,
"override_previous_animation" : true,
"bones" : {
"leftleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.life_time * 390.0 + 180.0) * 17.2, variable.swim_amount)", 0.0, 0.0 ]
},
"rightleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.life_time * 390.0) * 17.2, variable.swim_amount)", 0.0, 0.0 ]
}
}
},
"animation.player.swim.legs.single" : {
"loop" : true,
"override_previous_animation" : true,
"bones" : {
"leftleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.life_time * 390.0) * 17.2, variable.swim_amount)", 0.0, 0.0 ]
},
"rightleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.life_time * 390.0) * 17.2, variable.swim_amount)", 0.0, 0.0 ]
}
}
}
to this:
"animation.player.swim" : {
"loop" : true,
"bones" : {
"leftarm" : {
"rotation" : [ "math.lerp(0.0, (math.mod(query.modified_distance_moved, 26.0) < 22.0 ? 90.0 * math.clamp(math.mod(query.modified_distance_moved, 26.0) - 14.0, 0.0, 8.0) / 8.0 : 90.0 - 90.0 * (math.mod(query.modified_distance_moved, 26) - 22.0) / 4.0) - this, variable.swim_amount)", "math.lerprotate(0.0, 180.0 - this, variable.swim_amount)", "math.lerprotate(0.0, (math.mod(query.modified_distance_moved, 26.0) < 14.0 ? 180.0 + 107.18873 * math.mod(query.modified_distance_moved, 26.0) / 14.0 : 287.18873 - 107.18873 * math.clamp(math.mod(query.modified_distance_moved, 26) - 14.0, 0.0, 8.0) / 8.0) - this, variable.swim_amount)" ]
},
"rightarm" : {
"rotation" : [ "math.lerp(0.0, (math.mod(query.modified_distance_moved, 26.0) < 22.0 ? 90.0 * math.clamp(math.mod(query.modified_distance_moved, 26.0) - 14.0, 0.0, 8.0) / 8.0 : 90.0 - 90.0 * (math.mod(query.modified_distance_moved, 26) - 22.0) / 4.0) - this, variable.swim_amount)", "math.lerp(0.0, 180.0 - this, variable.swim_amount)", "math.lerp(0.0, (math.mod(query.modified_distance_moved, 26.0) < 14.0 ? 180.0 - 107.18873 * math.mod(query.modified_distance_moved, 26.0) / 14.0 : 72.81127 + 107.18873 * math.clamp(math.mod(query.modified_distance_moved, 26) - 14.0, 0.0, 8.0) / 8.0) - this, variable.swim_amount)" ]
},
"root" : {
"position" : [ 0.0, "math.sin(math.lerp(-90.0, query.target_x_rotation, variable.swim_amount)) * 17.0 + 17.0 - 12.0 * variable.swim_amount", "math.cos(math.lerp(-90.0, query.target_x_rotation * query.is_in_water, variable.swim_amount)) * 17.0" ],
"rotation" : [ "variable.swim_amount * (90.0 + query.target_x_rotation)", 0.0, 0.0 ]
}
}
},
"animation.player.swim.legs" : {
"loop" : true,
"bones" : {
"leftleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.modified_distance_moved * 19.09859 + 180.0) * 17.18873 - this, variable.swim_amount)", 0.0, 0.0 ]
},
"rightleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.modified_distance_moved * 19.09859) * 17.18873 - this, variable.swim_amount)", 0.0, 0.0 ]
}
}
},
"animation.player.swim.legs.single" : {
"loop" : true,
"bones" : {
"leftleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.modified_distance_moved * 19.09859) * 17.18873 - this, variable.swim_amount)", 0.0, 0.0 ]
},
"rightleg" : {
"rotation" : [ "math.lerp(0.0, math.cos(query.modified_distance_moved * 19.09859) * 17.18873 - this, variable.swim_amount)", 0.0, 0.0 ]
}
}
}
This fix also addresses MCPE-122663, and adds a smooth transition to the swimming pose for the limbs, which can't be done with a custom anim_time_update
and keyframes.
The math has been simplified as much as possible, using clamps instead of multiple conditions. It can be shortened further by replacing every instance of math.mod(query.modified_distance_moved, 26.0)
with a variable.
This bug didn’t happen before 1.13. It was introduced in 1.13. This also means that the swimming animation isn’t affected by MCPE-31931 anymore. So before 1.13 when you held down the jump key while swimming with the swimming animation, it used to make it slower, however this is not the case anymore because of this bug.