// Start is called before the first frame update void Start() { footPosL = GameObject.Find("LeftHandAnchor").transform.position; footPosR = GameObject.Find("RightHandAnchor").transform.position; isGroundTouch_R = ISGROUNDTOUCH.EndProcess; isGroundTouch_L = ISGROUNDTOUCH.EndProcess; audioSource = gameObject.GetComponent <AudioSource>(); }
void Start() { footConPos_R = rightHandAnchor.transform.position; footConPos_L = leftHandAnchor.transform.position; onlyOneTime = true; judgment = false; landingFlame = 0; bpmMove_Cube = GetComponent <BpmMove_Cube>(); bpmMove_DokudoCube = GetComponent <BpmMove_DokudoCube>(); isGroundTouch_R = ISGROUNDTOUCH.Stoping; isGroundTouch_L = ISGROUNDTOUCH.Stoping; isGroundTouch_R_Old = isGroundTouch_R; isGroundTouch_L_Old = isGroundTouch_L; }
// Update is called once per frame void Update() { if (only1Time) { if (footPosL.y <= footPosR.y)// 地面の位置を取得(初期値) { groundPosition.y = Mathf.Floor(footPosL.y * roundedDown) / roundedDown; } else { groundPosition.y = Mathf.Floor(footPosR.y * roundedDown) / roundedDown; } groundPosSave.y = groundPosition.y; groundPosSaveSave.y = groundPosition.y; only1Time = false; } footPosL = GameObject.Find("LeftHandAnchor").transform.position; footPosR = GameObject.Find("RightHandAnchor").transform.position; timeCheck += Time.deltaTime; //Debug.Log("前回の更新からの時間:" + timeCheck);// 経過時間のログ if (timeCheck >= timeRegulary)// 地面の位置を取得(更新) { timeCheck = 0.0f; if (footPosL.y <= footPosR.y) { lowFootPosition.y = Mathf.Floor(footPosL.y * roundedDown) / roundedDown; } else { lowFootPosition.y = Mathf.Floor(footPosR.y * roundedDown) / roundedDown; } if (lowFootPosition.y == groundPosition.y)// 地面と足の位置が同じとき { groundPosSave.y = lowFootPosition.y; groundPosSaveSave.y = lowFootPosition.y; } else// 地面と足の位置が違うとき { //Debug.Log("lowFootPosition" + lowFootPosition);// 更新したかどうかのログ //Debug.Log("groundPosSave" + groundPosSave);// 更新したかどうかのログ //Debug.Log("groundPosSaveSave" + groundPosSaveSave);// 更新したかどうかのログ if (lowFootPosition.y == groundPosSave.y && lowFootPosition.y == groundPosSaveSave.y) { groundPosition.y = lowFootPosition.y; //Debug.Log("更新3");// 更新したかどうかのログ } else if (lowFootPosition.y == groundPosSave.y) { groundPosSaveSave.y = lowFootPosition.y; //Debug.Log("更新2");// 更新したかどうかのログ } else { groundPosSave.y = lowFootPosition.y; //Debug.Log("更新1");// 更新したかどうかのログ } } } //Debug.Log(footPosL);// 左足の位置のログ //Debug.Log(footPosR);// 右足の位置のログ //Debug.Log("groundPosition"+ Mathf.Floor(groundPosition.y * roundedDown) / roundedDown);// 地面の位置のログ if (groundPosition.y + 0.03f < Mathf.Floor(footPosL.y * roundedDown) / roundedDown)// 左足上げているか否か { audioSource.clip = leftFoot; audioSource.Play(); onGroundL = false; //Debug.Log("左足");// 左足上げたのログ if (isGroundTouch_L == ISGROUNDTOUCH.EndProcess) { isGroundTouch_L = ISGROUNDTOUCH.JumpWait; } } else { onGroundL = true; if (isGroundTouch_L == ISGROUNDTOUCH.JumpWait) { isGroundTouch_L = ISGROUNDTOUCH.Landing; } } if (groundPosition.y + 0.03f < Mathf.Floor(footPosR.y * roundedDown) / roundedDown)// 右足上げているか否か { audioSource.clip = rightFoot; audioSource.Play(); onGroundR = false; //Debug.Log("右足");// 右足上げたのログ if (isGroundTouch_R == ISGROUNDTOUCH.EndProcess) { isGroundTouch_R = ISGROUNDTOUCH.JumpWait; } } else { onGroundR = true; if (isGroundTouch_R == ISGROUNDTOUCH.JumpWait) { isGroundTouch_R = ISGROUNDTOUCH.Landing; } } if (onGroundL == false && onGroundR == false && jumpSwtich == false) { jumpSwtich = true; Debug.Log("ジャンプ");// ジャンプしたのログ landingSwtich = false; } if (onGroundL == true && onGroundR == true && jumpSwtich == true) { landingSwtich = true; Debug.Log("着地");// 着地したのログ audioSource.clip = landing; audioSource.Play(); jumpSwtich = false; } //Debug.Log("onGroundL" + onGroundL);// 左足の位置のログ //Debug.Log("onGroundR" + onGroundR);// 右足の位置のログ //Debug.Log("jumpSwtich" + jumpSwtich);// ジャンプの位置のログ //Debug.Log("landingSwtich" + landingSwtich);// 着地の位置のログ }
// Update is called once per frame void Update() { if (only1Time) { if (footPosL.y <= footPosR.y)// 地面の位置を取得(初期値) { groundPosition.y = Mathf.Floor(footPosL.y * roundedDown) / roundedDown; } else { groundPosition.y = Mathf.Floor(footPosR.y * roundedDown) / roundedDown; } groundPosSave = groundPosition; groundPosSaveSave = groundPosition; only1Time = false; } footPosL = GameObject.Find("LeftHandAnchor").transform.position; footPosR = GameObject.Find("RightHandAnchor").transform.position; timeCheck += Time.deltaTime; if (timeCheck >= timeRegulary)// 地面の位置を取得(更新) { timeCheck = 0.0f; if (footPosL.y <= footPosR.y) { lowFootPosition.y = Mathf.Floor(footPosL.y * roundedDown) / roundedDown; } else { lowFootPosition.y = Mathf.Floor(footPosR.y * roundedDown) / roundedDown; } if (lowFootPosition.y == groundPosition.y)// 地面と足の位置が同じとき { groundPosSave.y = lowFootPosition.y; groundPosSaveSave.y = lowFootPosition.y; } else// 地面と足の位置が違うとき { if (lowFootPosition.y == groundPosSave.y && lowFootPosition.y == groundPosSaveSave.y) { groundPosition.y = lowFootPosition.y; } else if (lowFootPosition.y == groundPosSave.y) { groundPosSaveSave.y = lowFootPosition.y; } else { groundPosSave.y = lowFootPosition.y; } } } /* 左足の判定 */ if (isGroundTouch_L == ISGROUNDTOUCH.Wait)// 待ち { //Debug.Log("待ち"); if (groundPosition.y + tweak < Mathf.Floor(footPosL.y * roundedDown) / roundedDown)// 足を上げた { isGroundTouch_L = ISGROUNDTOUCH.Jump; } } else if (isGroundTouch_L == ISGROUNDTOUCH.Jump)// ジャンプ { //Debug.Log("ジャンプ"); if (groundPosition.y + tweak >= Mathf.Floor(footPosL.y * roundedDown) / roundedDown)// 足を地面につけた { isGroundTouch_L = ISGROUNDTOUCH.Landing; audioSource.clip = leftFoot; audioSource.Play(); } } else if (isGroundTouch_L == ISGROUNDTOUCH.Landing)// 着地 { //Debug.Log("着地"); } else if (isGroundTouch_L == ISGROUNDTOUCH.EndProcess)// 判定後 { //Debug.Log("判定後"); isGroundTouch_L = ISGROUNDTOUCH.Wait; } /* 右足の判定 */ if (isGroundTouch_R == ISGROUNDTOUCH.Wait)// 待ち { //Debug.Log("待ち"); if (groundPosition.y + tweak < Mathf.Floor(footPosR.y * roundedDown) / roundedDown)// 足を上げた { isGroundTouch_R = ISGROUNDTOUCH.Jump; } } else if (isGroundTouch_R == ISGROUNDTOUCH.Jump)// ジャンプ { //Debug.Log("ジャンプ"); if (groundPosition.y + tweak >= Mathf.Floor(footPosR.y * roundedDown) / roundedDown)// 足を地面につけた { isGroundTouch_R = ISGROUNDTOUCH.Landing; audioSource.clip = rightFoot; audioSource.Play(); } } else if (isGroundTouch_R == ISGROUNDTOUCH.Landing)// 着地 { //Debug.Log("着地"); } else if (isGroundTouch_R == ISGROUNDTOUCH.EndProcess)// 判定後 { //Debug.Log("判定後"); Debug.Log("波紋!"); isGroundTouch_R = ISGROUNDTOUCH.Wait; } }