I have tweened the ball from one point to other.

```
if(this.kick == false) return;
if (this.val > 1) return;
this.val += dt;
var target = KickFootball.v1;
target.lerp(this.src, this.des, this.ease( this.val ));
this.entity.setPosition(target);
```

I have tweened the ball from one point to other.

```
if(this.kick == false) return;
if (this.val > 1) return;
this.val += dt;
var target = KickFootball.v1;
target.lerp(this.src, this.des, this.ease( this.val ));
this.entity.setPosition(target);
```

Hi @yash_mehrotra,

If you arenâ€™t using physics you will have to use some equation to calculate that trajectory.

And these two things come to my mind that may be of help:

2 Likes

You can also find a maxima of the curve, say 2 meters to the side of a straight path which is from point A to point B.

You can find that normal by using a cross product of the path direction (from A to B) and an up vector (`pc.Vec3.UP`

or `pc.Vec3.DOWN`

, depending on whether you want go left or right from the path). Since we want 2 meters, we multiply the final vector by 2 and then lerp and add it to the target (just lerp it twice as fast, so that it would reach its maxima in the middle of the path, for example)

```
const offset = new pc.Vec3();
const pathDirection = endPoint.clone().sub(startPoint).normalize();
const side = new pc.Vec3().cross(pathDirection, pc.Vec3.UP).mulScalar(2);
const val = this.ease( this.val );
target.lerp(this.src, this.des, val);
// lerp from zero to 1, then back from 1 to zero
offset.lerp(pc.Vec3.ZERO, side, val < 0.5 ? val * 2 : 1 - (val * 2 - 1);
target.add(offset);
```

P.S. I typed here, so could be typos in the code, but you should get the idea.

Edit:

Oh you would need the appropriate easing function, so the curve looks alright (not a linear one at least). You can test some variants to see what matches your case.

2 Likes