n5ro / aframe-physics-system

Physics system for A-Frame VR, built on CANNON.js.
https://n5ro.github.io/aframe-physics-system/
MIT License
505 stars 136 forks source link

Can't change Ammo driver friction coefficient #198

Open AnaCoda opened 2 years ago

AnaCoda commented 2 years ago

How can I change the friction coefficient when using the Ammo driver?

I tried as follows: <a-scene physics=" driver: ammo; debug:true; debugDrawMode: 0; friction: 0.001;">, but nothing seems to change no matter what value I put for friction.

martaquintana commented 2 years ago

Hello, I had the same problem and for me works when i set restitiution after load all html file via javascript. You can try with attribute restitution


var sceneEl = document.querySelector('a-scene');
sceneEl.querySelector("#a-plane").body.setRestitution(0.8); 
aaishikdutta commented 2 years ago

Hello @martaquintana, setting restitution using setRestitution adds bounciness and not friction. What you're looking for @AnaCoda can be done using:

var sceneEl = document.querySelector('a-scene');
sceneEl.querySelector("#a-plane").body.setFriction(0.8); 

Also, a pointer to keep in mind that if you're importing a gltf model then you should probably try to listen for the body-loaded event then do the above.