# Ammo Character Collider

**URL:** <https://forum.babylonjs.com/t/ammo-character-collider/10059>\
**Category:** Questions\
**Created:** [April 16, 2020, 2:28pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059 "2020-04-16T14:28:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:28pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/1 "2020-04-16T14:28:38Z")

</div>

[https://playground.babylonjs.com/#79HPX7#5](https://playground.babylonjs.com/#79HPX7#5)

So what would be the best way to ensure that there is less “slide” with the sphere imposter that the camera is attached to?

Im using Ammo. I thought there was some specific way ammo calculates its rolling friction. Maybe I can dampen that? wsad controls

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 2:45pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/2 "2020-04-16T14:45:36Z")

</div>

Any chance for a SIMPLE playground, P8? (good to see u btw, hope ur well)

Top of head… change to box for more surface area for _friction_ to work better, or search forum for “leather” to find @RaananW’s Leather Boot professional damping system. 😉

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:47pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/3 "2020-04-16T14:47:15Z")

</div>

The only part you need to worry about is lines 35-45.

🙂 nice to see you too bud! been good. been busy.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 2:48pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/4 "2020-04-16T14:48:00Z")

</div>

But my coffee got cold… while waiting for load to finish. 🙂

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:48pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/5 "2020-04-16T14:48:43Z")

</div>

That’s odd, it shouldn’t. Might of been a PG loading thing not the scene.

The scene should compile really fast.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:51pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/6 "2020-04-16T14:51:03Z")

</div>

I was hoping setDamping would work, but its not seeming to do the trick.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 2:51pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/7 "2020-04-16T14:51:08Z")

</div>

About 25 seconds, even 2nd load without any cache-clear in-between. PBR = pig.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:51pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/8 "2020-04-16T14:51:48Z")

</div>

What kinda rig you got? Im interested now, cause I have a toaster and it loads in like fractions of a second for me.

So maybe there is something in my code.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:52pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/9 "2020-04-16T14:52:14Z")

</div>

ohh is it the reflectionTexture, I could prolly programmatically generate that too. to save that from loading.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 2:54pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/10 "2020-04-16T14:54:03Z")

</div>

Are you sure cameraRoot.body.physicsBody.setDamping(0.0,1) is working? Tested well?

(oh, you already commented on that, sorry)

umm… I have 12 year old Dell Inspiron… win 7… pretty good internet. This unit plays GTA 5 nicely, podracer, mudrunner, fsx with no scenery extras. Dunno how else to describe.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:54pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/11 "2020-04-16T14:54:22Z")

</div>

I think its the reflectionTexture bogging on the load.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 2:57pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/12 "2020-04-16T14:57:01Z")

</div>

So when we say we have ammo js as a physics plugin… how much of it do we really have?

Because I am looking at the classes from bullet which ammo is supposed to be a direct port of it, and I have a bunch of methods that seem to not work on the btRigidBody, maybe Im just doing things wrong.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 3:05pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/13 "2020-04-16T15:05:12Z")

</div>

> [@Pryme8](#):
>
> maybe Im just doing things wrong

You are… hehe. (j/k) Don’t confuse AmmoPlugin with Ammo PE. AmmoPlugin was designed to sort-of “mirror” the power and features of the other 2 plugins. As far as “added value” on Ammo plugin… not sure there is any (such as soft Body). Look at docs… JohnK and the boys DID write some stuff for softbody and rope impostors… did it well… but MAYBE not seen on the plugin. Maybe need to go native to operate. But ammo PE… is exact full-featured native engine, afaik.

Also, BJS physics IMPOSTOR class and physics ENGINE class… are the same for all three PE’s, I believe. By doing that, we might lose some features from Ammo, because… BJS impostor class is a bit too “dumb” to handle all of Ammo’s power. I don’t think anyone wrote a special PI class just for Ammo… and thus… our current PI class doesn’t do softbodies, I believe. Must go native to use… not activate-able at BJS plugin, PI, or PE class layers.

Add lots of Ammo power to BJS plugin, PI, or PE layers, and those objects no longer mirror the plugin, PI, or PE API’s of the earlier PE’s (Oimo and Cannon). That’s my take on it all. 🙂

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 16, 2020, 3:09pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/14 "2020-04-16T15:09:27Z")

</div>

but you can access those methods if you pass the right values it looks like

```auto
cameraRoot.body.physicsBody.applyCentralImpulse(new physicsPlugin.bjsAMMO.btVector3(0, 10, 0))

```

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 3:11pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/15 "2020-04-16T15:11:23Z")

</div>

Yeah, that’s native-level talk… not experienced with that. Sorry. Certainly doesn’t look-like Cannon or Oimo native, but that’s expected.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 16, 2020, 3:14pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/16 "2020-04-16T15:14:46Z")

</div>

> [@Pryme8](#):
>
> new physicsPlugin.bjsAMMO.btVector3(0, 10, 0)

Not sure that bs is needed.

Maybe just `new bjsAMMO.btVector3(0, 10, 0)` or `new AMMO.btVector3(0, 10, 0)`

Like I’d know. Done playground in-code searches for pertinent keywords? Wise.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [April 21, 2020, 1:25pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/17 "2020-04-21T13:25:40Z")

</div>

> [@Wingnut](#):
>
> As far as “added value” on Ammo plugin… not sure there is any (such as soft Body). Look at docs… JohnK and the boys DID write some stuff for softbody and rope impostors… did it well… but MAYBE not seen on the plug

Wingnut was well-wrong on that. I did some touring of the AmmoJS plugin this morning, and it has many features specifically designed-for AmmoJS. Sorry for misleading on that. Wingnut not paying proper attention. 😕

I’m sniffing your [bug report](https://forum.babylonjs.com/t/clothimposter-cant-have-different-numbers-of-subdivisions-on-x-and-y/), P8.

Wingy’s test PG: [https://www.babylonjs-playground.com/#9NMQVY#8](https://www.babylonjs-playground.com/#9NMQVY#8) Hit any key to drop the cover. Adjusters in lines 27-30 - for setting differing amounts of x/y subdivs.

Studying the issue, trying to determine what the story is. Lightly pondering… [https://github.com/BabylonJS/Babylon.js/blob/master/src/Physics/Plugins/ammoJSPlugin.ts#L736](https://github.com/BabylonJS/Babylon.js/blob/master/src/Physics/Plugins/ammoJSPlugin.ts#L736) (two _segments_ params - perhaps should be xSegments and ySegments?) (wild speculating) 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [April 22, 2020, 11:03am UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/18 "2020-04-22T11:03:25Z")

</div>

Adding @Cedric just in case he can shine some lights on the issue.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [April 22, 2020, 1:19pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/19 "2020-04-22T13:19:36Z")

</div>

First parameter for setDamping is for velocity, second is for torque.  
I replaced the 0 for velocity with 0.999, increased the maxspeed and it gives less momentum movements:  
[https://playground.babylonjs.com/#79HPX7#59](https://playground.babylonjs.com/#79HPX7#59)  
drawback is it fells way slower now.  
Another way is to increase the friction value, decrease the restitution.  
You’ll have to tweak the velocity but it shouldn’t be too hard:  
[https://playground.babylonjs.com/#79HPX7#60](https://playground.babylonjs.com/#79HPX7#60)

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 22, 2020, 1:26pm UTC](https://forum.babylonjs.com/t/ammo-character-collider/10059/20 "2020-04-22T13:26:29Z")

</div>

I ended up figuring it out. Did some experiments with ammos Kinematic controller which sucks horribly… Ended up going with my own controller.

Ill post a cooler version once I am done with my work for the week hopefully. but here is a “working” prototype.  
[https://playground.babylonjs.com/#79HPX7#55](https://playground.babylonjs.com/#79HPX7#55)

@Cedric helped me out a little and it made me realize that sometimes you just gotta do yourself.
