A框运动相机高度问题 [英] A-Frame Kinematic-body camera height problem

查看:87
本文介绍了A框运动相机高度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我需要我的相机成为运动体并与墙元素碰撞,但是我无法使其保持在y轴的固定高度1.6。我需要一种方法来将锥度保持在这个高度,同时保持其运动体属性,因为我需要撞墙才能起作用。我已经附上了到目前为止所坚持的代码。

I have a problem where I need my camera to be a Kinematic-body and collide with wall elements however I cannot get it to stay at a fixed y-axis height of 1.6. I need a way to keep the camer a this height while maintaining its kinematic-body attribute because I need wall collisions to work. I have attached the code which I have been stuck on so far.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://aframe.io/releases/1.0.3/aframe.min.js"></script>
    <script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v4.0.1/dist/aframe-physics-system.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.0/dist/aframe-extras.min.js"></script>
    <script src="https://rawgit.com/rdub80/aframe-gui/master/dist/aframe-gui.min.js"></script> <!--GUI Library-->
    <script src="https://unpkg.com/aframe-environment-component@1.1.0/dist/aframe-environment-component.min.js"></script> <!--Environment extension-->
    <title>Courtyard and Entrance Scene</title>

</head>
<body>
    <a-scene physics="debug: true">
        
            <a-entity id="camera" position="0 1.6 0" camera look-controls wasd-controls="acceleration: 400" kinematic-body>
                <a-cursor></a-cursor>
                <a-gui-label 
                        id="playerLocation"
                        width="1" height="0.2"
                        font-size="4.5rem"
                        padding="1rem 2rem"
                        position="2 1.5 -2"
                        value="gui label"
                >
                </a-gui-label>
            </a-entity>
            
            <!-- Floor -->
            <a-plane static-body material="color: grey" width="15" height="15" rotation="-90 0 0" position="0 0 0"></a-plane>
            
            <a-box width="10" height="5" depth="0.5" static-body material="color: red" position="0 0 -5"></a-box>
            
    </a-scene>
</body>
</html>

任何对此问题的见解将不胜感激!

Any insight into this problem would be greaty appreciated!

推荐答案

在使用装备时,偏移量可以正确计算:

The offsets are calculated properly when a rig is used:

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

小提琴。

这篇关于A框运动相机高度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆