We are encountering a fundamental issue in our basketball-themed game, which utilizes an animation asset pack from Unity:
https://assetstore.unity.com/packages/3d/animations/aa-basic-basketball-movement-animations-package-260347?srsltid=AfmBOopgHAUdvjqtSQubyCzyiWZK1knjfiOX7SCdvNyJ624bymXdn1Sm
While the asset itself works as expected, our custom dribble mechanic follows a different approach. Specifically, the dribble motion is driven by a sin wave directly implemented within the base mechanic class called BaseDribble.
public virtual void Tick(CharacterController character)
{
var runtimeData = character.RuntimeData;
var staticData = character.StaticData;
if (runtimeData.hasGatheredStep || !runtimeData.hasBall || !runtimeData.isDribbling) return;
// Dribbling logic
runtimeData.ball.transform.position = character.BallPosition_RightHand.position + Vector3.down * Mathf.Abs(Mathf.Sin(Time.time * staticData.dribbleSpeed) / staticData.dribbleHeight);
}
However, when we attempt to blend this mechanic with the provided dribble animation, the resulting motion appears unnatural or visually inconsistent, as demonstrated below:
https://drive.google.com/file/d/1yQD6bTeQEP20-r5jiCu02duYp1mcNZhQ/view?usp=sharing
After several rounds of experimentation and research, I discovered a more flexible approach shifting the bounce behavior logic from the codebase to the animation state machine itself.
This allows the animation to control the dribble’s timing and bounce naturally while maintaining synchronization with the in-game physics and ball movement system.
After analyzing the problem, we transitioned from a code-driven dribble system (which used a sine wave to simulate bounce) to an animation-synchronized dribble system using Unity’s StateMachineBehaviour.