Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class KinectInput : MonoBehaviour {
- public static Vector3 leftWristPosition;
- public static Vector3 rightWristPosition;
- public float turnValue;
- public int coeffecientValue;
- public float deltaZMax = 0.35f;
- // Use this for initialization
- void Start () {
- turnValue = 0;
- coeffecientValue = 0;
- }
- // Update is called once per frame
- void Update () {
- // this debug is only for testing purpose
- Debug.Log(GetTurnValue());
- }
- public float GetTurnValue()
- {
- // Debug.Log(" LeftWrist Value: " + leftWristPosition.z);
- //Debug.Log("RightWrist Value:" + rightWristPosition.z);
- if (rightWristPosition.z > leftWristPosition.z)
- {
- Debug.Log("right turn...");
- coeffecientValue = 1;
- }
- else if (rightWristPosition.z < leftWristPosition.z)
- {
- Debug.Log("left turn...");
- coeffecientValue = -1;
- }
- else
- {
- Debug.Log("No input .....");
- coeffecientValue = 0;
- }
- float deltaZ = Mathf.Abs(leftWristPosition.z - rightWristPosition.z);
- turnValue = deltaZ / deltaZMax;
- if(turnValue < 0.04f)
- {
- return 0;
- }
- else if (turnValue >= 1.0f)
- {
- return 1 * coeffecientValue;
- }
- else
- {
- return turnValue * coeffecientValue;
- }
- // Debug.Log("TempTurnValue: " + tempTurnValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement