Search code examples
htmlaframe

A-Camera Still moves though a-mixin after static-body has been applied


So, I'm adding aframe physics (this one) and when I apply static-body to the a-mixin voxel on the Minecraft demo I can still move through the box.

My camera is set to universal-controls.

Here is where I put the static body:

    <a-assets>
       <a-mixin id="voxel" 
         static-body geometry="primitive: box; height: 0.6; width:0.6; 
         depth: 0.6" material="id: theImage; src: Box.jpg; color: 
         #696969; roughness: 1; metalness: 0" 
         snap="offset: 0.4 0.4 0.4; snap: 0.6 0.6 0.6">
       </a-mixin>
    </a-assets>

Solution

  • While using aframe-extras (physics-based movement section) and aframe-physics if you set up your camera in a rig with a kinematic-body:

    <a-entity id="rig" movement-controls kinematic-body>
       <a-entity camera position="0 1.6 0" look-controls></a-entity>
    </a-entity>
    

    It should collide with any entities, that are either static-body or dynamic-body.

    <a-box static-body></a-box>
    <a-box dynamic-body></a-box>
    


    - Custom fiddle here. Dynamic, and static bodies.
    - Minecraft demo here. If you make a 3x1 pole, you won't move through it. You'll "jump" over the 2x1 blocks though.