basic push back on virtual red wall

game-mechanics
Fabien Benetou 2 years ago
parent f7a22ed8a6
commit 78689f5a5d
  1. 19
      index.html

@ -2956,6 +2956,8 @@ AFRAME.registerComponent('dynamic-unless-picked', {
// should unregister on remove
})
// e.g usage within player entity :
// <a-entity position=".5 0 0" collider-check raycaster="far:5; interval: 1000; objects: .cubes; showLine:true;" ></a-entity>
AFRAME.registerComponent('collider-check', {
dependencies: ['raycaster'],
@ -2977,6 +2979,21 @@ AFRAME.registerComponent('collider-check', {
}
});
// e.g usage within player entity :
// <a-entity position="0 -1.6 0" rotation="-25 0 0" collision-check raycaster="far:.2; interval: 100; objects: .cubes; showLine:true;" ></a-entity>
AFRAME.registerComponent('collision-check', {
dependencies: ['raycaster'],
init: function () {
this.el.addEventListener('raycaster-intersection', function (e) {
color = e.detail.els[0].getAttribute("color")
let rig = document.getElementById("rig").getAttribute("position")
if (color == "red")
rig.z += .5
});
}
});
// used for testing
AFRAME.registerComponent('startfunctions', {
init: function () {
@ -3017,7 +3034,7 @@ AFRAME.registerComponent('startfunctions', {
<a-sound id="snapping-sound" src="url(../content/magnets_snap.mp3)"></a-sound>
<a-entity id="player" networked="template:#avatar-template;attachTemplateToLocal:false;"
hud camera look-controls wasd-controls waistattach="target: .movebypinch" position="0 1.6 0">
<a-entity position=".5 0 0" collider-check raycaster="far:5; interval: 1000; objects: .cubes; showLine:true;" ></a-entity>
<a-entity position="0 -1.6 0" rotation="-25 0 0" collision-check raycaster="far:.2; interval: 100; objects: .cubes; showLine:true;" ></a-entity>
</a-entity>
<a-entity id="rightHand" pinchprimary hand-tracking-controls="hand: right;"></a-entity>
<a-entity id="leftHand" pinchsecondary wristattachsecondary="target: #box" hand-tracking-controls="hand: left;"></a-entity>

Loading…
Cancel
Save