我用一個kinect做了一個遊戲(pong),我可以識別一個骷髏,並且我可以做出手勢來控制左邊的杖,但是當我試圖和兩個玩家一起玩時,不會識別這個骷髏其他玩家。這是我到目前爲止:識別兩個骷髏Kinect
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
Skeleton[] skeletons = new Skeleton[0];
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null)
{
skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo(skeletons);
}
if (skeletons.Length != 0)
{
foreach (Skeleton skel in skeletons)
{
if (skel.TrackingState == SkeletonTrackingState.Tracked)
{
this.tracked(skel);
this.trackedLeft(skel);
}
}
}
}
}
public void tracked(Skeleton skeleton)
{
Joint jHandRight = skeleton.Joints[JointType.HandRight];
Joint jHipCenter = skeleton.Joints[JointType.HipCenter];
if ((jHipCenter.Position.Z - jHandRight.Position.Z) > 0.2)
{
//Consider hand raised in front of them
//System.Diagnostics.Debug.WriteLine("Hand: Raised");
//MessageBox.Show("POR FAVORRRRRRRR");
//movement[0] = false;
movement[0] = true;
movement[1] = false;
}
else
{
//Hand is lowered by the users side
//System.Diagnostics.Debug.WriteLine("Hand: Lowered");
//MessageBox.Show("A SERRRRIIIIIOOOOOOOOOOOOOO");
//movement[1] = false;
movement[1] = true;
movement[0] = false;
}
}
有人可以幫助我。
如何區分玩家1和玩家2? –
目前我無法區分,我讀到kinect可以識別兩個玩家......也許給ID,但不知道該怎麼辦 – seal