example of jumping (tested on desktop only, assuming ground at 0)

game-mechanics
Fabien Benetou 2 years ago
parent fa10d07e73
commit 01f04c4229
  1. 6
      index.html

@ -3005,6 +3005,10 @@ AFRAME.registerComponent('collision-check', {
} }
}); });
function jump(){
document.getElementById("rig").emit(`jump`, null, false)
}
// used for testing // used for testing
AFRAME.registerComponent('startfunctions', { AFRAME.registerComponent('startfunctions', {
init: function () { init: function () {
@ -3040,7 +3044,7 @@ AFRAME.registerComponent('startfunctions', {
</template> </template>
</a-assets> </a-assets>
<a-entity id="rig"> <a-entity id="rig" animation="property: position.y; to: 0.4; dir: alternate; loop:1; startEvents:jump; dur: 400">
<a-sound src="../content/street-crowd-ambience.mp3" autoplay=true loop=true volume=0.2></a-sound><!-- warning skipped on Quest, does autoplay there --> <a-sound src="../content/street-crowd-ambience.mp3" autoplay=true loop=true volume=0.2></a-sound><!-- warning skipped on Quest, does autoplay there -->
<a-sound id="snapping-sound" src="url(../content/magnets_snap.mp3)"></a-sound> <a-sound id="snapping-sound" src="url(../content/magnets_snap.mp3)"></a-sound>
<a-entity id="player" networked="template:#avatar-template;attachTemplateToLocal:false;" <a-entity id="player" networked="template:#avatar-template;attachTemplateToLocal:false;"

Loading…
Cancel
Save