Collisions and cloners issue

Hi!

I have an issue that is kinda a problem. playground: https://www.babylonjs-playground.com/#Z0QW21#30

So You can look around, shoot balls, and are teleported to where the balls land. At line 95(?) I create shammo, which allows a function in the update loop detect when it is touching the ground. I then repeatedly remake the variable when you click and call the pewpew function. The problem is that when you shoot more than one ball, only the last one teleports you and the others don’t. I was given the suggestion to use a cloner, but I’m not sure how to. The documentation is a little sparse.

Any help would be great.

It makes sense why only the last one would work, as you are only checking in the update if the most recent shammo is intersecting. I would say you need to have a way to check all active shammos for intersecting, and if so, teleport to that specific ones. I think there could be performance issues there though, testing would be required. There are probably quite a few routes you could go. Maybe only checking the ground for collisions would have better performance.

Unsure what you mean by cloner, but regardless in the current state I think changing createInstance to clone will not change anything.

I tried creating instances, but was unable to track them (I made a loop)

If you can help me decipher the idea of using a clones as seen here: Loop created objects with physics impostors have issues

This isn’t the first time I’ve tried to ask!

I’ll try to make a super clear explanation with pictures.

Unsure why a loop wouldn’t work for you.
https://www.babylonjs-playground.com/#Z0QW21#33

looks to work fine for me with instances.

It freezes for me when I click :confused:

EDIT: nvm it works. thanks for the help!

Yea, it was a popped not being defined actually issue.
https://www.babylonjs-playground.com/#Z0QW21#35
Just in case.

whoops. In early iterations you could press s to “pop” as shot. You would teleport to the shot where it was.

Btw, you can use /* and */ as multiline comments.
https://www.babylonjs-playground.com/#Z0QW21#36
look at the update loop

Lol I know, but Ctrl + K, Ctrl + C is much faster.

ctrl+c = copy
ctrl+k = ?

what does ctrl+k do?

you highlight some text then do ctrl+k first, then ctrl+c and it comments those lines at the beginning. If you want to uncomment, it is ctrl+k, ctrl+u.

Huh. never tried that. Thanks for the tip!