const track = new animation.VectorTrack();
track.componentsCount = 3;
track.path = new animation.TrackPath().toProperty('position');
const [x,y,z] = track.channels();
const vec3KeyFrames = [
[0, peopleStartPos],
[time, new Vec3(endX, endY, 0)]
] as [number, Vec3][];
x.curve.assignSorted(vec3KeyFrames.map(([time, vec3]) => [time, { value: vec3.x }]));
y.curve.assignSorted(vec3KeyFrames.map(([time, vec3]) => [time, { value: vec3.y }]));
const animationClip = new AnimationClip();
animationClip.duration = time;
animationClip.name = "tt";
animationClip.addTrack(track);
const nodeAnimation = peopleNode.getComponent(Animation) ||
peopleNode.addComponent(Animation);
const clips = nodeAnimation.clips;
for(let i=0,ilen=clips.length;i<ilen;i++){
if(clips[i].name === "ToBorder"){
nodeAnimation.removeClip(clips[i],true);
}
}
nodeAnimation.addClip(animationClip,"ToBorder");
nodeAnimation.play("ToBorder");
如上代码,一个人物从开始位置移动到目标位置,通过以上代码实现动画位移,在移动到该目标位置后,目标会随着游戏进展变化位置,需要人物跟随目标变化,从新执行上述代码,计算出来的目标位置endx endy会变化,但是执行动画后没有变化,请问多批次位移动画是否可以用该方式来实现。