I am doing exact same thing with this post but updating position along the path with motionPath is just making position (0,0) for each frame. What is causing this?
Codepen: https://codepen.io/alparslanahmed/pen/dyLQorr?editors=0011
const path2 = [{x:ball.x, y:ball.y}, {x: cp2x, y: 40}, {x: target.x-ball.x,y:target.y-ball.y}]
console.log(ball.x, ball.y)
gsap.to(ball, {
duration: 1,
motionPath:{
path: path2,
type: 'cubic'
},
onUpdate: () => {
console.log(ball.x, ball.y)
},
onComplete: () => {
console.log("complete")
if (ballInfo.target < this.pins.children.length) {
ballInfo.target++;
this.moveBall(ball, index);
} else {
// End of animation logic
}
}
});