Bullet trajectory

I need to show a bullet’s flight from a player to a mesh and make some effect.

I use something of that:

const velocity = new BABYLON.Vector3(
  Math.sin(parseFloat(this.viseur.rotation.y)),
  -Math.sin(parseFloat(this.viseur.rotation.x)),
  Math.cos(parseFloat(this.viseur.rotation.y))
);
this.bullet.moveWithCollisions(velocity);

But, when I aim to meshes in different distances, the bullet does not collide where I have aimed.
How to resolve it?

This usually happens on fast moving elements they move so fast that 2 checks are one before and one after the object. In case of bullet you could use a raycast instead of move with collision to gain a lot in precision.

1 Like