# Collisions and cloners issue

**URL:** https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280
**Category:** Questions
**Created:** [April 1, 2019, 3:33pm UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280 "2019-04-01T15:33:31Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)
#### Post date: [April 1, 2019, 3:33pm UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/1 "2019-04-01T15:33:31Z")

</div>

Hi!

I have an issue that is kinda a problem. playground: [https://www.babylonjs-playground.com/#Z0QW21#30](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.

---

<div class="post-metadata">

### Author: ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)
#### Post date: [April 2, 2019, 12:06am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/2 "2019-04-02T00:06:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)
#### Post date: [April 2, 2019, 12:08am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/3 "2019-04-02T00:08:40Z")

</div>

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](https://forum.babylonjs.com/t/loop-created-objects-with-physics-impostors-have-issues/2204/4)

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

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

---

<div class="post-metadata">

### Author: ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)
#### Post date: [April 2, 2019, 12:14am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/4 "2019-04-02T00:14:47Z")

</div>

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

looks to work fine for me with instances.

---

<div class="post-metadata">

### Author: ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)
#### Post date: [April 2, 2019, 12:16am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/5 "2019-04-02T00:16:21Z")

</div>

It freezes for me when I click 😕

EDIT: nvm it works. thanks for the help!

---

<div class="post-metadata">

### Author: ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)
#### Post date: [April 2, 2019, 12:21am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/6 "2019-04-02T00:21:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)
#### Post date: [April 2, 2019, 12:24am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/7 "2019-04-02T00:24:34Z")

</div>

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](https://www.babylonjs-playground.com/#Z0QW21#36)  
look at the update loop

---

<div class="post-metadata">

### Author: ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)
#### Post date: [April 2, 2019, 12:53am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/8 "2019-04-02T00:53:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)
#### Post date: [April 2, 2019, 12:54am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/9 "2019-04-02T00:54:29Z")

</div>

ctrl+c = copy  
ctrl+k = ?

what does ctrl+k do?

---

<div class="post-metadata">

### Author: ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)
#### Post date: [April 2, 2019, 1:28am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/10 "2019-04-02T01:28:53Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)
#### Post date: [April 2, 2019, 1:31am UTC](https://forum.babylonjs.com/t/collisions-and-cloners-issue/2280/11 "2019-04-02T01:31:35Z")

</div>

Huh. never tried that. Thanks for the tip!
