Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unity3d GetVelocitiesAtTimeOffset未提供预期值_Unity3d_Virtual Reality_Steam_Steamvr - Fatal编程技术网

Unity3d GetVelocitiesAtTimeOffset未提供预期值

Unity3d GetVelocitiesAtTimeOffset未提供预期值,unity3d,virtual-reality,steam,steamvr,Unity3d,Virtual Reality,Steam,Steamvr,我正在开发一个用于索引的应用程序,并尝试使用提供的GetVelocitiesAtTimeOffset获取控制器的历史速度。我似乎无法让它返回正确的值 例如,我试着在过去的5秒内以1秒的增量回溯时间来检查速度,它在过去的5秒内不断给我相同的精确速度值,即使我在晃动控制器。作为一个基本的健全性测试,我试着在每一帧打印5秒前的控制速度,当我移动控制器时,我看到值立即改变,而不是像我预期的那样在未来的5秒 我想我可能会检查未来的值而不是过去的值(尽管有文档),但是尽管时间偏移值为负值或正值,行为似乎没

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

例如,我试着在过去的5秒内以1秒的增量回溯时间来检查速度,它在过去的5秒内不断给我相同的精确速度值,即使我在晃动控制器。作为一个基本的健全性测试,我试着在每一帧打印5秒前的控制速度,当我移动控制器时,我看到值立即改变,而不是像我预期的那样在未来的5秒

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

我希望能够确定在给定的时间范围内,双手y速度何时高于阈值

        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 hand1Velocity, out _);
                    hand2.trackedObject.GetVelocitiesAtTimeOffset(i, out hand2Velocity, out _);
                    Debug.Log("Hand1: " + hand1Velocity + ", Hand2: " + hand2Velocity);
                 }
            }

            return result;
        }
private bool checkVelocity\u bothHandsUp(手动1、手动2、浮动过去时间顺序、浮动步长){
布尔结果=真;
//应检查从现在起到过去的历史速度不确定度、采样步长。
对于(浮点i=0;i>=-1.0*pastTimeInSeconds;i-=pastTimeInSeconds/步){
Vector3 Hand1速度=Vector3.0;
Vector3 hand2速度=Vector3.0;
hand1.trackedObject.GetVelocitiesAtTimeOffset(5.0f,out hand1速度,out 2;);
hand2.trackedObject.GetVelocitiesAtTimeOffset(5.0f,out hand2速度,out 2;);
if(hand1Velocity.y=-1.0*pastTimeInSeconds;i-=pastTimeInSeconds/步){
Vector3 Hand1速度=Vector3.0;
Vector3 hand2速度=Vector3.0;
hand1.trackedObject.GetVelocitiesAtTimeOffset(i,out hand1速度,out_1;);
hand2.trackedObject.GetVelocitiesAtTimeOffset(i,out hand2速度,out_2;);
Log(“Hand1:+hand1Velocity+”,Hand2:+hand2Velocity);
}
}
返回结果;
}

每一组速度间隔1秒,回溯到5秒