void isSquat(playerSkeleton pri, playerSkeleton now) { if (state.squat == 0 && ((Mathf.Abs(pri.head.y - now.head.y)) > squatDistence) && state.flag != 0 && (pri.head.y - now.head.y) > 0 && state.isSquating()) { state.squat = 1; //跳起 } }
void isJump(playerSkeleton pri, playerSkeleton now) { if (state.jump == 0 && ((Mathf.Abs(pri.head.y - now.head.y)) > jumpDistence) && state.flag != 0 && (pri.head.y - now.head.y) < 0 && state.isJumping() && pri.head.y != 0) { state.jump = 1; //跳起 } }
void isRight(playerSkeleton pri, playerSkeleton now) { if (state.right == 0 && now.Right_Hand.z - now.head.z > leftDistence && state.flag != 0 && state.isRighting()) { state.right = 1; //跳起 //StartCoroutine(stopSkeleton(1, false)); //for (float i = 0; i < 10; i += Time.deltaTime) ; } }
void isLeft(playerSkeleton pri, playerSkeleton now) { //} if (state.left == 0 && now.Left_Hand.z - now.head.z > leftDistence && state.flag != 0 && state.isLefting()) { state.left = 1; //跳起 //StartCoroutine(stopSkeleton(1 , true)); } }
// Update is called once per frame void Update() { pSkeleton = player.GetComponent <Player>().GetSkeleton(); Head.transform.position = new Vector3(pSkeleton.head.x, pSkeleton.head.y - 150, pSkeleton.head.z); LF.transform.position = pSkeleton.Left_Hand; LE.transform.position = pSkeleton.Left_ELBOW; RF.transform.position = pSkeleton.Right_Hand; RE.transform.position = pSkeleton.Right_ELBOW; Body.transform.position = pSkeleton.TORSO; }
void Start() { //a = 0; //b = 0; //c = 0; //p = 0; //StartCoroutine(getSkeleton(a, b, c)); skeleton = new float[19]; for (int i = 0; i < 19; i++) { skeleton[i] = 0; } StartNewThread(); nowPlayerSk = new playerSkeleton(); priPlayerSk = new playerSkeleton(); state = new playerState(0, 0, 0, 0, 0, 0, 1); }
void getCoordSkeleton(playerSkeleton playerSkl) { //float x = 0, y = 0, z = 0; //for (int i = 0; i < 6; i++) { // x += b[i * 3]; // y += b[i * 3 + 1]; // z += b[i * 3 + 2]; //} //x /= 6; //y /= 6; //z /= 6; playerSkl.head = new Vector3(skeleton[0] / accuracy, skeleton[1] / accuracy, skeleton[2] / accuracy); playerSkl.Left_ELBOW = new Vector3(skeleton[3] / accuracy, skeleton[4] / accuracy, skeleton[5] / accuracy); playerSkl.Left_Hand = new Vector3(skeleton[6] / accuracy, skeleton[7] / accuracy, skeleton[8] / accuracy); playerSkl.Right_ELBOW = new Vector3(skeleton[9] / accuracy, skeleton[10] / accuracy, skeleton[11] / accuracy); playerSkl.Right_Hand = new Vector3(skeleton[12] / accuracy, skeleton[13] / accuracy, skeleton[14] / accuracy); playerSkl.TORSO = new Vector3(skeleton[15] / accuracy, skeleton[16] / accuracy, skeleton[17] / accuracy); }