I don't know why, but sometimes when multiple users connected they spawn in a different position which I didn't specify anywhere in my code.
<a-entity >
<a-entity
id="avatar"
networked="template:#avatar-template;attachTemplateToLocal:false;"
movement-controls="constrainToNavMesh: true"
spawn-in-circle="radius:3"
position="-15 0.770 25"
>
<a-entity
class="cam"
networked="template:#head-template;attachTemplateToLocal:false;"
camera="active: true"
position="0 2.5 0"
look-controls
>
<a-sphere
class="head"
id="local-avatar"
visible="true"
random-color
></a-sphere>
</a-entity>
</a-entity>
</a-entity>
This is the code I've written for the networked entity. I've given position="-15 0.770 25", but camera is spawning in another position. Which ruins all the things like speed, constraints.
<script>
NAF.schemas.getComponentsOriginal = NAF.schemas.getComponents;
NAF.schemas.getComponents = (template) => {
if (!NAF.schemas.hasTemplate("#head-template")) {
NAF.schemas.add({
template: "#head-template",
components: [
"position",
"rotation",
{
selector: ".head",
component: "material",
property: "color",
},
],
});
}
const components = NAF.schemas.getComponentsOriginal(template);
return components;
};
</script>
This for registering the entity in a-frame.