projectile decay example

game-mechanics
Fabien Benetou 2 years ago
parent 5c0762d59b
commit 63d05ef64d
  1. 3
      index.html

@ -3068,8 +3068,9 @@ function shoot(){
shot = setInterval( _ => {
d+=.1;
r.at(d, t);
t.y-=.1*(1+d) // simulating gravity and friction
s.setAttribute("position", AFRAME.utils.coordinates.stringify( t ));
if (d>100) clearInterval(shot)
if (d>100 || t.y < 0) clearInterval(shot)
}, 10)
}

Loading…
Cancel
Save