网络a型框架中的定位问题
我不知道为什么,但有时当多个用户连接时,它们会在不同的位置生成,而我没有在代码中的任何位置指定。
<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>
这是我为网络实体编写的代码。我已经给出了 position="-15 0.770 25",但相机在另一个位置生成。这破坏了所有的东西,比如速度、限制。
<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>
这用于在框架中注册实体。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论