void Update() { // dont run Update() if there is no user KinectManager kinectManager = KinectManager.Instance; if (autoChangeAlfterDelay && (!kinectManager || !kinectManager.IsInitialized() || !kinectManager.IsUserDetected())) { return; } if (!isSpinning) { if (slideChangeWithKeys) { if (Input.GetKeyDown(KeyCode.PageDown)) { RotateToNext(); } else if (Input.GetKeyDown(KeyCode.PageUp)) { RotateToPrevious(); } } if (slideChangeWithGestures && gestureListener) { if (gestureListener.IsSwipeLeft()) { RotateToNext(); } else if (gestureListener.IsSwipeRight()) { RotateToPrevious(); } } // check for automatic slide-change after a given delay time if (autoChangeAlfterDelay && Time.realtimeSinceStartup >= slideWaitUntil) { RotateToNext(); } } else { // spin the presentation transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, spinSpeed * Time.deltaTime); // check if transform reaches the target rotation. If yes - stop spinning float deltaTargetX = Mathf.Abs(targetRotation.eulerAngles.x - transform.rotation.eulerAngles.x); float deltaTargetY = Mathf.Abs(targetRotation.eulerAngles.y - transform.rotation.eulerAngles.y); if (deltaTargetX < 1f && deltaTargetY < 1f) { // delay the slide slideWaitUntil = Time.realtimeSinceStartup + slideChangeAfterDelay; isSpinning = false; } } }
// Update is called once per frame void Update() { if (gestureListener) { if (gestureListener.IsSwipeLeft()) { PlayerController.instance.MoveRight(); Debug.Log("Kinect动作识别后左移"); } if (gestureListener.IsSwipeRight()) { PlayerController.instance.MoveLeft(); Debug.Log("Kinect动作识别后右移"); } if (gestureListener.IsJumpUp()) { PlayerController.instance.JumpUp(); Debug.Log("Kinect动作识别后跳跃"); } } }
void Update() { moveCamera(); //pa que no corra si no hay gente presente KinectManager kinectManager = KinectManager.Instance; //if (!kinectManager || !kinectManager.IsInitialized() || !kinectManager.IsUserDetected()) // return; //****************OTRO SCRIPT*********************************************************************************** if (slideChangeWithGestures && gestureListener) { Debug.Log("i= " + i); Debug.Log("control= " + control); /*if (gestureListener.IsSwipeLeft()) * { * incremento(); * * } * else if ((gestureListener.IsSwipeRight()) ) * { * decremento(); * } * else*/if ((Input.GetKeyUp(KeyCode.D) || gestureListener.IsSwipeLeft()) && (i != 8)) { //Input.get Debug.Log("i== " + i + " Dentro de swipe izquierda"); if (control == true) { incremento(); } else { RotateToNext(); } } else if ((Input.GetKeyUp(KeyCode.A) || gestureListener.IsSwipeRight()) && (i >= 0)) { Debug.Log("i== " + i + " Dentro de swipe derecha"); if ((control == false) && i == 0) { decremento(); } else { RotateToPrevious(); } } else if (/* Input.GetKey(KeyCode.I) ||*/ gestureListener.IsPush() && camara.fieldOfView >= MIN) { Acercar(); Debug.Log("i== " + i + " Dentro de push"); } else if (/*Input.GetKey(KeyCode.O) ||*/ gestureListener.IsPull() && camara.fieldOfView <= MAX) { alejar(); Debug.Log("i== " + i + " Dentro de pull"); } /*else if ((size == false) && (i == 0) && ((gestureListener.IsJump() || Input.GetKey(KeyCode.Space)))) * { * decremento(); * * } * else if ((size == true) && (i == 0) && Input.GetKey(KeyCode.Space)) * { * incremento(); * }*/ //moveCamera(); Debug.Log("x = " + camara.transform.eulerAngles.x + "// y=" + camara.transform.eulerAngles.y + "z= " + camara.transform.eulerAngles.z); } }
void Update() { // dont run Update() if there is no gesture listener if (!gestureListener) return; if (!isMoving) { if (Input.GetKeyDown(KeyCode.RightArrow)) { MoveUp(); controller.MoveUp(); } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { MoveDown(); controller.MoveDown(); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { MoveLeft(); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { MoveRight(); } if (gestureListener) { if (gestureListener.IsSwipeRight()) { MoveUp(); controller.MoveUp(); } else if (gestureListener.IsSwipeLeft()) { MoveDown(); controller.MoveDown(); } else if (gestureListener.IsSwipeUp()) { //MoveUp(); } } } else { if (stepsToGo > 0) { if (dir == 1) { posx -= 0.1f; } else if (dir == 2) { posx += 0.1f; } else if (dir == 3) { posz += 0.1f; } else if (dir == 4) { posz -= 0.1f; } stepsToGo--; } else { isMoving = false; dir = 0; } } obj.gameObject.transform.position = new Vector3(posx, posy, posz); }
// Update is called once per frame void Update() { if (controller.isGrounded && count.isCountDown) { GetComponent <Animation>().Play("run"); if (Input.GetKeyDown("left") || gestureListener.IsFlyLeft()) { location = CalculateMotion((int)controller.GetComponent <Transform>().localPosition.x, -1); } else if (Input.GetKeyDown("right") || gestureListener.IsFlyRight()) { location = CalculateMotion((int)controller.GetComponent <Transform>().localPosition.x, 1); } else { location = CalculateMotion((int)controller.GetComponent <Transform>().localPosition.x, 0); } //moveDirection = new Vector3(tempVectorValue, 0, 0); //moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0); //moveDirection = transform.TransformDirection(moveDirection); //moveDirection *= speed; if (pause.paused == false && pause.enabled == true) { gameObject.GetComponent <AudioSource>().enabled = true; } else if (pause.paused == true || count.isCountDown == false) { gameObject.GetComponent <AudioSource>().enabled = false; } if (Input.GetKeyDown("left") || gestureListener.IsSwipeLeft()) { location = CalculateMotion((int)controller.GetComponent <Transform>().localPosition.x, -1); } else if (Input.GetKeyDown("right") || gestureListener.IsSwipeRight()) { location = CalculateMotion((int)controller.GetComponent <Transform>().localPosition.x, 1); } else { location = CalculateMotion((int)controller.GetComponent <Transform>().localPosition.x, 0); } //moveDirection = new Vector3(tempVectorValue, 0, 0); //moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0); // moveDirection = transform.TransformDirection(moveDirection); // moveDirection *= speed; if (Input.GetButton("Jump")) { GetComponent <Animation>().Stop("run"); GetComponent <Animation>().Play("jump_pose"); jumpSound.Play(); gameObject.GetComponent <AudioSource>().enabled = false; moveDirection.y = jumpSpeed; } else if (gestureListener.IsFlap()) { GetComponent <Animation>().Stop("run"); GetComponent <Animation>().Play("jump_pose"); jumpSound.Play(); gameObject.GetComponent <AudioSource>().enabled = false; moveDirection.y = jumpSpeed; } if (controller.isGrounded) //recursive, extra one, not nessacary { isGrounded = true; } if (control.isGameOver) { gameObject.GetComponent <AudioSource>().enabled = false; } } if (((gestureListener.IsRaiseLeftHand() || gestureListener.IsRaiseRightHand())) && !count.enabled) { Debug.Log("CountDownStart" + gestureListener.IsRaiseRightHand()); StartCountDown(); } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); //used for jump controller.transform.localPosition = new Vector3(location, controller.GetComponent <Transform>().position.y, -7); }
void Update() { // dont run Update() if there is no user (safety checks to ensure it) KinectManager kinectManager = KinectManager.Instance; if (!kinectManager || !kinectManager.IsInitialized() || !kinectManager.IsUserDetected()) { return; } if (!isSpinning && !isPulling && !isExiting) { // here we can set the animation to perform if (gestureListener) { bool IsInOriginalPos = Math.Abs(originalPosition.z - transform.position.z) < 1f; if (gestureListener.IsSwipeLeft() && IsInOriginalPos) { RotateToNext(); } else if (gestureListener.IsSwipeRight() && IsInOriginalPos) { RotateToPrevious(); } else if (gestureListener.IsPulling() && IsInOriginalPos) // si entra aquí desactiva los otros { AnimatePush(false); } else if (gestureListener.IsExiting() && !IsInOriginalPos) { AnimatePush(true); } } } else if (isSpinning) // there is a current rotation in action { // spin the presentation transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, spinSpeed * Time.deltaTime); // check if transform reaches the target rotation. If yes - stop spinning float deltaTargetX = Mathf.Abs(targetRotation.eulerAngles.x - transform.rotation.eulerAngles.x); float deltaTargetY = Mathf.Abs(targetRotation.eulerAngles.y - transform.rotation.eulerAngles.y); if (deltaTargetX < epsilon && deltaTargetY < epsilon) { // delay the slide isSpinning = false; } } else if (isPulling || isExiting) // there is a current translation in action // animate the presentation { transform.position = Vector3.Lerp(transform.position, targetTranslation, translationSpeed * Time.deltaTime); // check if transform reaches the target translation. If yes - stop translating float deltaTargetZ = Mathf.Abs(targetTranslation.z - transform.position.z); if (deltaTargetZ < epsilon) { // delay the slide if (isPulling) { isPulling = false; } if (isExiting) { isExiting = false; } } } }
void Update() { // dont run Update() if there is no user KinectManager kinectManager = KinectManager.Instance; /*if(autoChangeAlfterDelay && (!kinectManager || !kinectManager.IsInitialized() || !kinectManager.IsUserDetected())) * return;*/ if (!kinectManager || !kinectManager.IsInitialized() || !kinectManager.IsUserDetected()) { return; } if (!isSpinning) { /*if(slideChangeWithKeys) * { * if(Input.GetKeyDown(KeyCode.A)) * RotateToNext(); * else if(Input.GetKeyDown(KeyCode.D)) * RotateToPrevious(); * } */ if (slideChangeWithGestures && gestureListener) { if (gestureListener.IsSwipeLeft()) { RotateToNext(); } else if (gestureListener.IsSwipeRight()) { RotateToPrevious(); } } // check for automatic slide-change after a given delay time /* if(autoChangeAlfterDelay && Time.realtimeSinceStartup >= slideWaitUntil) * { * RotateToNext(); //creo que es pa las imagenes mas qe todo * }*/ } //else // { // spin the presentation //transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, spinSpeed * Time.deltaTime); // check if transform reaches the target rotation. If yes - stop spinning /*float deltaTargetX = Mathf.Abs(targetRotation.eulerAngles.x - transform.rotation.eulerAngles.x); * float deltaTargetY = Mathf.Abs(targetRotation.eulerAngles.y - transform.rotation.eulerAngles.y); * * if(deltaTargetX < 1f && deltaTargetY < 1f) * { * // delay the slide * slideWaitUntil = Time.realtimeSinceStartup + slideChangeAfterDelay; * isSpinning = false; * } * } * Debug.Log("global side: " + side); */ }