Blend tree configuration
Blend options
Blend weights and control functions
function LocomotionCharacter({ speed }) {
const { weights, setParameter, updateWeights } = useAnimationBlend({
type: '1d',
parameter: 'speed',
nodes: [
{ animation: 'idle', threshold: 0 },
{ animation: 'walk', threshold: 0.5 },
{ animation: 'run', threshold: 1.0 }
]
});
useEffect(() => {
setParameter('speed', speed);
updateWeights();
}, [speed, setParameter, updateWeights]);
return (
<group>
{Object.entries(weights.weights).map(([name, weight]) => (
<Animation key={name} name={name} weight={weight} />
))}
</group>
);
}
React hook for animation blending with blend trees.
Manages blend weights between multiple animations based on parameters, useful for locomotion and directional movement.