[英]Extracting separate co-ordinates of a game object
I am currently working on a school project where I'll be using motion capture and unity. 我目前正在做一个学校项目,我将使用运动捕捉和统一性。 It's made for the elderly to improve their cognitive and motoric functions. 它是为提高老年人的认知和运动功能而设计的。 I want unity to be able to record their movements into a CSV file to see how well they are doing. 我希望团结能够将他们的动作记录到CSV文件中,以查看他们的状况如何。 I want the x, y and z co-ordinate recorded against time in excel. 我想要在Excel中记录时间的x,y和z坐标。
I'm using perception neuron for my motion capture which has a total of 32 sensors. 我将感知神经元用于运动捕捉,共有32个传感器。 The 3D model in unity has 32 different parts/limbs that move, including the fingers. 统一的3D模型具有32个可移动的不同部分/肢体,包括手指。 I added a picture of it here: 我在这里添加了一张图片:
Now in this code, I can't seem to get the coordinates of a limb (i'm just trying to get the coordinates of a single limb for now). 现在在这段代码中,我似乎无法获取肢体的坐标(我现在只是想获取单个肢体的坐标)。 I struggling with trying to extract the gameobject's coordinates. 我努力尝试提取游戏对象的坐标。 But I tried splitting Vector3 into x, y, z coordinates to get separate coordinates and also because I want the values to be float too but it does not seem to work could anyone help me with this? 但是我尝试将Vector3拆分为x,y,z坐标以获取单独的坐标,并且还因为我也希望这些值也浮动,但似乎不起作用,有人可以帮助我吗?
Here's my code: 这是我的代码:
using UnityEngine;
using System.Collections.Generic;
using System;
using System.IO;
public class Test : MonoBehaviour
{
float timer = 100.0f;
public TestSO so ;
StreamWriter motionData;
public void Start()
{
string fullFilename = @"C:\Users\Administrator\Desktop\CsvPlz.csv";
motionData = new StreamWriter(fullFilename, true);
InvokeRepeating("wolf", 0.0f, 0.5f);
}
void wolf()
{
timer += Time.deltaTime;
string delimiter = ", ";
var position : Vector3;
var x: float = position[0];
var y : float = position[1];
var z : float = position[2];
if (timer > 1.0f)
{
timer -= 1.0f;
string dataText = ("{1}",x) + delimiter + ("{2}", y) + delimiter + ("{3}", z);
motionData.WriteLine(dataText);
}
motionData.Close();
}
}
Change 更改
var position : Vector3;
var x: float = position[0];
var y : float = position[1];
var z : float = position[2];
To 至
Vector3 position = Vector3.One;
float x = position.x;
float y = position.y;
float z = position.z;
the variables xy and z are optional, as Vector3 already contains floats. 变量xy和z是可选的,因为Vector3已经包含浮点数。 You could just use position.x directly. 您可以直接使用position.x。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.