Question by
takkeuchio · Sep 27, 2017 at 02:52 AM ·
vector3
HTC viveコントローラの取得値の移動平均(フィルタ)について
Unity初心者です. 現在,HTC viveのコントローラのPositionとRotationを取得し,オブジェクトを取得した数値に反映させて動かそうとしています. そこで,取得する数値を安定させるためフィルタや移動平均を使用しようとしたのですが,プログラムをうまく書けません.
アドバイスをいただけると幸いです. よろしくお願いいたします.
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Larm_control : MonoBehaviour {
public GameObject Con;
void Start()
{
StartCoroutine(loop());
}
void Example()
{
Con = GameObject.Find("Larm_Hand");
}
IEnumerator loop()
{
while (true) {
yield return new WaitForSeconds (0f);
float px = Con.transform.position.x;
float py = Con.transform.position.y;
float pz = Con.transform.position.z;
float rx = Con.transform.eulerAngles.x;
float ry = Con.transform.eulerAngles.y;
float rz = Con.transform.eulerAngles.z;
this.transform.position = new Vector3 (px, py, pz);
this.transform.eulerAngles = new Vector3 (rx, ry, rz);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
c# help with rotate and rotatearound 0 Answers
iron sight using inverse kinematic 0 Answers
How to disable diagonal Vector3 movement of non-player object using MoveTowards? 1 Answer
prob to define a condition to get out of a search position loop for obstacle avoidance 0 Answers
Creating a new vector3 2 Answers