soundvision/UnityProject/Assets/Scenes/Examples/KinectSkeleton/scripts/Skeleton.cs
max 54c8e907c4 Force Balls Test
Emmit Particles with one hand
Attract them with the other
2019-11-09 18:42:47 +01:00

40 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Kinect;
using UnityEngine;
namespace cylvester
{
public class Skeleton : MonoBehaviour
{
[SerializeField] private GameObject spherePrefab;
private GameObject[] balls_;
private void Start()
{
balls_ = new GameObject[25];
for (var i = 0; i < 25; ++i)
{
balls_[i] = Instantiate(spherePrefab, gameObject.transform, true);
}
}
public void OnSkeletonDataReceived(Body body, int id)
{
var i = 0;
foreach(var pair in body.Joints)
{
var joint = pair.Value;
if(joint.TrackingState == TrackingState.NotTracked)
balls_[i].SetActive(false);
else
{
balls_[i].SetActive(true);
balls_[i].transform.position = new Vector3(joint.Position.X * 10f , joint.Position.Y * 10f, joint.Position.Z *10f);
}
i++;
}
}
}
}