Monday 12 July 2021

A-frame trigger function when two objects touch

I am wondering how I can achieve something in A-frame where when two objects touch, a function called myFunction() is triggered with a one second delay. This means that if the objects are continuously touching, there will be a 1 second delay before the next function is triggered. How can this be done? Simple example:

<html>
  <head>
    <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
  </head>
  <body>
    <a-scene>
      <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
      <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
      <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
      <a-sky color="#ECECEC"></a-sky>
    </a-scene>
  </body>
</html>

I would ideally like to trigger a function each 1 second called myFunction that the sphere and square are touching. How can this be done?



from A-frame trigger function when two objects touch

No comments:

Post a Comment