Loop created objects with physics impostors have issues

In my game I am using spheres with physics as like a teleport mechanism. Here is the playground: https://www.babylonjs-playground.com/#Z0QW21#29

An issue I am having is that the shot spheres can’t collide with each other, and on other thing. But first, here is a rundown of the playground.

Use the mouse to look around and left click to shoot. You will be teleported to where the ball landed. Line 98 creates the ball, and the pewpew function after it is called when you left click. It restates the variable, so it makes another ball. At lines 260-268 it detects when the ball hits the ground and destroys the ball, and teleports you to where it landed.

Ok. so the first issue is look straight down and spam left click. I mean fast! eventually some balls will bunch up, move slow, not collide with each other, and don’t teleport you.

The second is that only the last ball can teleport you. shoot one straight and then shoot one forward. only the last ball will teleport you. Can this not happen.

Thanks for any help.


Summoning @trevordev

the filtering group needs to be set on the ammo to also collide with the ammo https://www.babylonjs-playground.com/#Z0QW21#30

If you want all the balls to teleport you, you will need to create an array of them and iterate over all of them in your update loop

Thanks for the help!

This will do nicely. :wink:

I haven’t looked at your scene, but based upon the post it sounds as though cloned meshes and impostors might work for you. This has always been a reliable method to generate different geometry and physics objects.


I have tried an instanced mesh but not a cloned one. I’ll give it a try. maybe it might fix another issue that I’m having.

Btw, for the longest time I thought darth sidious was your profile pic.