Shadow gets blockier after a while

I’m making a soccer penalty shooting game. I use Ammo as physics engine and a Shadowgenerator to make the shadow of the ball.

I apply an impulse to the ball to shoot it. After shooting, the ball position is reset.
To remove the impulse to the ball I use:

      ball.physicsImpostor.setLinearVelocity(BABYLON.Vector3.Zero());
      ball.physicsImpostor.setAngularVelocity(BABYLON.Vector3.Zero());

After this I can shoot the ball again.
The problem is that after a while (like 50 shots), the shadow of the ball gets blocky and eventually disappears.

I have no idea why this happens.
Any ideas?

Welcome aboard!

Maybe it’s the same problem than in:

2 Likes

Hello @Dylan2022 just checking in if you need any more help?

Thank you carol, I think I found what caused this. Some objects kept on falling down, after they were shot off the field, causing the shadowgenerator to do weird things.

I now dispose all objects when they are below y=0, so this doesn’t happen anymore.

1 Like