KINECT attach an array of objects to array of bodies
im trying to assign objects to left and right hand bone and move them where the hand is going but I really dont know how array works
using UnityEngine; using System.Collections; using Windows.Kinect;
public class DetectJoints : MonoBehaviour {
public GameObject BodySrcManager;
public GameObject Glow;
public JointType[] TrackedRight;
public JointType[] TrackedLeft;
private BodySourceManager bodymanager;
private Body[] bodies;
// Use this for initialization
void Start () {
if (BodySrcManager == null) {
} else {
bodymanager = BodySrcManager.GetComponent<BodySourceManager>();
}
}
// Update is called once per frame
void Update () {
if (bodymanager == null) {
return;
}
bodies = bodymanager.GetData ();
if (bodies == null) {
return;
}
foreach (var body in bodies) {
if( body == null){
continue;
}
if(body.IsTracked){
foreach (var tright in TrackedRight){
var pos = body.Joints[TrackedRight].Position;
GameObject glowright = (GameObject) Instantiate (Glow, new Vector3((float)i, 1, 0), Quaternion.identity );
glowright.transform.position = new Vector3 (pos.X, pos.Y, pos.Z);
//GameObject objects = (GameObject) Instantiate(element.iconPrefab, transform.position, transform.rotation);
}
// GameObject GlowCheck = GameObject.FindGameObjectWithTag("GlowObject");
// if (!GlowCheck){
// Instantiate (Glow, Vector3.zero, Quaternion.identity);
// }
// GlowCheck.transform.position = new Vector3 (pos.X, pos.Y, pos.Z);
//gameObject.transform.position = new Vector3(pos.X, pos.Y, pos.Z);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to instantiate an item when i catching it with kinect? 0 Answers
Help Kinect SDK add in error! 0 Answers
How can I track only a certain part of the body with Kinect 2 in Unity?? 0 Answers
Black screen when play test my Unity application Using Oculus Rift and Microsoft Kinect 1 Answer
Rotation doesn't work with JointOrientation from kinect in Unity3D 5 1 Answer