// Use this for initialization void Start() { // Find a Kinect sensor KinectSensorCollection kinectSensors = KinectSensor.KinectSensors; if (kinectSensors.Count == 0) { this.sensor = null; throw new UnityException("Could not find a Kinect sensor."); } // Enable the skeleton stream this.sensor = kinectSensors[0]; this.sensor.SkeletonStream.Enable(); if (!this.sensor.SkeletonStream.IsEnabled) { throw new UnityException("Sensor could not be enabled."); } // Create the input processor inputProcessor = new InputProcessor(this.sensor.CoordinateMapper, DepthImageFormat.Resolution320x240Fps30); this.InputInfo = inputProcessor.GameInputInfo; Debug.Log("Hello"); return; }
// Update is called once per frame void Update() { // Get the input info SeatedInfo personInfo = this.inputContoller.playerInfo; GameInputInfo inputInfo = this.inputContoller.InputInfo; if (inputInfo == null) { return; } // Set the player position and direction if (personInfo.Features == null) { return; } //Debug.Log (inputInfo.Features.Position); //this.transform.position = new Vector2(0, -(inputInfo.Features.Position.y)) * 5; //this.transform.forward = new Vector2(0, -(inputInfo.Features.Direction.y)) * 5; //this.transform.rotation = new Quaternion(0, 0, -1*(inputInfo.Features.Angle/(90)) * rotateSpeed * Time.deltaTime, 1); if (inputInfo.SoldierInfo.IsSkeletonAvailable) { if (personInfo.Features.Position.y < 0.95f) { transform.Translate(Vector3.up * (Player.speed + 1) * Time.deltaTime); } else if (personInfo.Features.Position.y > 1.1f) { transform.Translate(Vector3.down * (Player.speed + 4) * Time.deltaTime); } transform.Rotate(0, 0, -1 * (personInfo.Features.Angle / (30)) * Player.rotateSpeed * Time.deltaTime); //this.transform.up = new Vector2(personInfo.Features.Direction.x, personInfo.Features.Direction.y) * 50; print(personInfo.Features.Position.y); /*Debug.Log (personInfo.Features.Angle); * * transform.Rotate (0, 0, -1 * (personInfo.Features.Angle / (90)) * Player.rotateSpeed * Time.deltaTime); * * Player.speed += personInfo.Features.Position.y * Player.speed * Time.deltaTime; * * Player.speed = Mathf.Clamp (Player.speed, 1, 10); */ if (inputInfo.SoldierInfo.IsSkeletonAvailable) { Debug.Log("Skeleton available."); } return; } }
// Update is called once per frame void Update() { // Retrieve skeleton data using (SkeletonFrame frame = this.sensor.SkeletonStream.OpenNextFrame(0)) { if (frame != null) { // Allocate memory if needed if (skeletonData == null || skeletonData.Length != frame.SkeletonArrayLength) { skeletonData = new Skeleton[frame.SkeletonArrayLength]; } frame.CopySkeletonDataTo(skeletonData); } } // Compute game input this.InputInfo = inputProcessor.ProcessData(skeletonData); GameInputInfo inputInfo = InputInfo; // Set the soldier position if (inputInfo.SoldierInfo.IsSkeletonAvailable) { if (inputInfo.SoldierInfo.Position > 0) { MoveRight(); RotateRight(); } else if (inputInfo.SoldierInfo.Position < 0) { MoveLeft(); RotateLeft(); } Debug.Log(inputInfo.SoldierInfo.Position); //this.transform.position = Vector3.right * 3f * inputInfo.SoldierInfo.Position; } else { this.transform.position = Vector3.zero; } if (inputInfo.SoldierInfo.IsSkeletonAvailable) { Debug.Log("Skeleton available."); } }
// Update is called once per frame void Update() { // Retrieve skeleton data using (SkeletonFrame frame = this.sensor.SkeletonStream.OpenNextFrame(0)) { if (frame != null) { // Allocate memory if needed if (skeletonData == null || skeletonData.Length != frame.SkeletonArrayLength) { skeletonData = new Skeleton[frame.SkeletonArrayLength]; } frame.CopySkeletonDataTo(skeletonData); } } // Compute game input this.InputInfo = inputProcessor.ProcessData(skeletonData); if (skeletonData == null) { return; } // Compute seated infos SeatedInfo[] seatedInfos = this.seatedInputProcessor.ComputeSeatedInfos(skeletonData); // Get seated skeleton int skeletonIndex = -1; for (int i = 0; i < skeletonData.Length; i++) { if (seatedInfos[i].Posture == Posture.Seated) { skeletonIndex = i; } } // Compute seated info if (skeletonIndex != -1) { this.playerInfo = seatedInfos[skeletonIndex]; Debug.Log("Tracking skeleton."); } return; }
// Update is called once per frame void Update() { // Retrieve skeleton data using (SkeletonFrame frame = this.sensor.SkeletonStream.OpenNextFrame(0)) { if (frame != null) { // Allocate memory if needed if (skeletonData == null || skeletonData.Length != frame.SkeletonArrayLength) { skeletonData = new Skeleton[frame.SkeletonArrayLength]; } frame.CopySkeletonDataTo(skeletonData); } } // Compute game input this.InputInfo = inputProcessor.ProcessData(skeletonData); return; }
// Update is called once per frame void Update() { // Get the input info GameInputInfo inputInfo = this.inputController.InputInfo; // Set the soldier position if (inputInfo.SoldierInfo.IsSkeletonAvailable) { this.transform.position = Vector3.right * 3f * inputInfo.SoldierInfo.Position; } else { this.transform.position = Vector3.zero; } if (inputInfo.SoldierInfo.IsSkeletonAvailable) { Debug.Log("Skeleton available."); } return; }
// Use this for initialization void Start() { // Find a Kinect sensor KinectSensorCollection kinectSensors = KinectSensor.KinectSensors; if(kinectSensors.Count == 0) { this.sensor = null; throw new UnityException("Could not find a Kinect sensor."); } // Enable the skeleton stream this.sensor = kinectSensors[0]; this.sensor.SkeletonStream.Enable(); if(!this.sensor.SkeletonStream.IsEnabled) throw new UnityException("Sensor could not be enabled."); // Create the input processor inputProcessor = new InputProcessor(this.sensor.CoordinateMapper, DepthImageFormat.Resolution320x240Fps30); this.InputInfo = inputProcessor.GameInputInfo; this.seatedInputProcessor = new SeatedInfoProcessor (); Debug.Log("Hello"); return; }
// Update is called once per frame void Update() { // Retrieve skeleton data using(SkeletonFrame frame = this.sensor.SkeletonStream.OpenNextFrame(0)) { if(frame != null) { // Allocate memory if needed if(skeletonData == null || skeletonData.Length != frame.SkeletonArrayLength) { skeletonData = new Skeleton[frame.SkeletonArrayLength]; } frame.CopySkeletonDataTo(skeletonData); } } // Compute game input this.InputInfo = inputProcessor.ProcessData(skeletonData); if (skeletonData == null) { return; } // Compute seated infos SeatedInfo[] seatedInfos = this.seatedInputProcessor.ComputeSeatedInfos (skeletonData); // Get seated skeleton int skeletonIndex = -1; for (int i=0; i<skeletonData.Length; i++) { if(seatedInfos[i].Posture == Posture.Seated) skeletonIndex = i; } // Compute seated info if (skeletonIndex != -1) { this.playerInfo = seatedInfos[skeletonIndex]; Debug.Log ("Tracking skeleton."); } return; }