GetVelocitiesAtTimeOffset没有给出期望值

问题描述

我正在开发用于索引的应用程序,并且试图使用提供的GetVelocitiesAtTimeOffset来获取控制器的历史速度。我似乎无法让它返回正确的值。

Steam API documentation

例如,我尝试通过在过去5秒钟内以1秒的增量返回时间来检查速度,即使在过去5秒钟内,它也始终为我提供相同的准确速度值摇晃控制器。作为一项基本的健康测试,我试图在每帧上准确打印5秒钟前的速度,当我移动控制器时,我看到的是值立即变化,而不是像我期望的那样在未来5秒钟

我以为我可能会检查将来的值而不是过去的值(尽管有文档),但是尽管时间偏移量是负值或正值,但行为似乎并没有改变。我还尝试将毫秒值用于timeoffset而不是记录的秒数,并且得到了相同的行为。此方法返回的布尔值始终为“ true”。

我希望能够确定在给定时间范围内两只手的速度何时超过阈值。

        private bool checkVelocity_bothHandsUp(Hand hand1,Hand hand2,float pastTimeInSeconds,float step) {
            bool result = true;

            // Should check historical velocities from now until pastTimeInSeconds,sampling step times.
            for(float i = 0; i >= -1.0*pastTimeInSeconds; i -= pastTimeInSeconds/step) {
                Vector3 hand1Velocity = Vector3.zero;
                Vector3 hand2Velocity = Vector3.zero;
                hand1.trackedObject.GetVelocitiesAtTimeOffset(5.0f,out hand1Velocity,out _);
                hand2.trackedObject.GetVelocitiesAtTimeOffset(5.0f,out hand2Velocity,out _);

                if (hand1Velocity.y < velocityThreshold || hand2Velocity.y < velocityThreshold ) {
                    result = false;
                }
            }

            // If every sampled velocity.y is above the threshold we say that both hand objects have been moving
            //  up for the entirety of the sampled duration.
            if (result == true) {
                Debug.Log("Both hands were moving up");
                // Debug to print the last velocities seen if moving up
                for(float i = 0; i >= -1.0*pastTimeInSeconds; i -= pastTimeInSeconds/step) {
                    Vector3 hand1Velocity = Vector3.zero;
                    Vector3 hand2Velocity = Vector3.zero;
                    hand1.trackedObject.GetVelocitiesAtTimeOffset(i,out _);
                    hand2.trackedObject.GetVelocitiesAtTimeOffset(i,out _);
                    Debug.Log("Hand1: " + hand1Velocity + ",Hand2: " + hand2Velocity);
                 }
            }

            return result;
        }

Link to the print statement results.

每组速度相隔一秒,返回5秒。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)