【发布时间】:2022-11-02 18:42:44
【问题描述】:
我想在 Unity 中更改手部跟踪的增益,但是当我尝试移动手部时遇到了一些问题。 确实,当我尝试移动右手时,会出现一个错误,告诉我手的位置是无穷大。你对此有什么想法吗?我在论坛上看到了很多东西,但我不明白是什么问题。
这是我的代码:
// Variables
public GameObject hand;
public GameObject handRenderer;
private Vector3 posOrigin;
// Settings
public float gain;
// Start is called before the first frame update
void Start()
{
Vector3 posOrigin = handRenderer.transform.position;
}
// Update is called once per frame
void Update()
{
float dx = transfo(handRenderer.transform.position.x, posOrigin.x);
float dz = transfo(handRenderer.transform.position.z, posOrigin.z);
hand.transform.position = new Vector3(posOrigin.x + dx, 0, posOrigin.z + dz);
}
float transfo ( float origin, float actual )
{
return gain * (actual - origin);
}
手部渲染器是我计算的重点,因为它不能直接与对象 RightHand 一起使用。 非常感谢
【问题讨论】:
标签: c# unity3d unityscript