Hey all so I am trying to build an aframe scene with a fps view. I have made the gun-model the child of the player-model to create an avatar template. My idea was to attach the camera to the avatar using , and then updating the position of the avatar with the camera using .getAttribute(‘position’). Would this work? Im having trouble keeping the avatar’s position constant with the camera. Here’s my body.html for reference:
<!-- Copyright (c) 2023 8th Wall, Inc. -->
<!-- body.html is optional; elements will be added to your html body after app.js is loaded. -->
<a-scene
networked-scene="adapter: sharedar; connectOnLoad: true"
lobby-handler
lobby-pages
xrextras-loading
xrextras-runtime-error
xrextras-gesture-detector>
<a-assets>
<a-asset-item id="player-model" src="./assets/models/player.glb"></a-asset-item>
<a-asset-item id="gun-model" src="./assets/models/gun.glb"></a-asset-item>
<template id="avatar-template">
<a-entity health-controller basic-collider character-animator death-animation>
<a-entity
gltf-model="#player-model"
scale="2.5 2.5 2.5"
position="0 0 0"
rotation="0 180 0">
<a-entity
gltf-model="#gun-model"
scale="1 1 1"
position=".3 1.5 0.5"
rotation="0 -90 0">
</a-entity>
</a-entity>
</a-entity>
</template>
</a-assets>
<a-camera
id="camera"
position="0 4.3 -.5"
raycaster="objects: .cantap"
cursor="fuse: false; rayOrigin: mouse;">
</a-camera>
<a-entity
id="player"
networked="template: #avatar-template; attachTemplateToLocal: false"
position="0 0 0"
player-logic>
<a-camera
position="0 4.3 -.5"
raycaster="objects: .cantap"
cursor="fuse: false; rayOrigin: mouse;"
camera-sync>
<a-entity id="health-bar" position="0 -0.5 -1">
<a-plane width="0.5" height="0.1" color="yellow">
<a-text value="Health" color="red" align="center" position="0 0.05 0.1" scale="0.4 0.4 0.4"></a-text>
</a-plane>
</a-entity>
</a-camera>
</a-entity>
</a-scene>