/* * tack player positions every frame. */ public void Update() { if (bodyFrameReader != null) { var frame = bodyFrameReader.AcquireLatestFrame(); if (frame != null) { frame.GetAndRefreshBodyData(bodies); players.Clear(); foreach (var body in bodies) { /* * If the player is being tracked calculate the position and orientation. */ if (body.IsTracked) { #if UNITY_EDITOR Debug.Log("Tracking " + body.TrackingId + " --- " + "Right hand state: " + body.HandRightState + " --- " + "Right hand confidence: " + body.HandRightConfidence); #endif var pos = body.Joints[JointType.HandRight].Position; Vector3 position = new Vector3(pos.X, pos.Y, pos.Z); var ori = body.JointOrientations[JointType.HandRight].Orientation; Quaternion orientation = new Quaternion(ori.X, ori.Y, ori.Z, ori.W); #if UNITY_EDITOR Debug.Log("Position: " + position); Debug.Log("Orientation: " + orientation); #endif PlayerTracking player = new PlayerTracking(position, orientation, body.HandRightState); players.Add(player); } } frame.Dispose(); frame = null; } } }
private void InitializeKI() { astar = new AStar(); astar.PathFound += new PathFoundEventHandler(astar_PathFound); nodeTex = Content.Load<Texture2D>("Stuff/Node"); font = Content.Load<SpriteFont>("Stuff/Arial"); if (enemyvariables[EnemyVariables.PlayerTracking].Trim() == PlayerTracking.Tracking.ToString()) { tracking = PlayerTracking.Tracking; usesKI = true; } else tracking = PlayerTracking.NotTracking; //timeFromLastSearch = 0; }