public void JumpOnGround() { //从平台跌落,设置三段跳(因为跌落后执行,所以在跌落的那一帧,会没来得及设置三段跳,因此在这也设置一次) SettingJumpTime(); //起跳条件1 if (InputMgr.Instance.catInput.KeyA.WasPressed) { //print("readyJump"); readyJump = true; } if (InputMgr.Instance.catInput.KeyA.IsPressed) { //起跳条件2 if (readyJump) { //普通跳或二段跳 if ((role.groundDct.IsOnGround() && groundDct.IsStandable()) || groundDct.IsOnIceground()) { //print("跳1"); if (groundDct.timeStand >= groundDct.minTimeStand) { //记录滑落方向 role.moveProc.lastSlideVector = role.slideProc.slideVector; _JumpOnGround(jumpSpeed); } } else if (remainJumpTimes > 0) { //print("状态:" + role.state + "," + groundDct.disGround + "," + remainJumpTimes); //特别接近地面时,禁止使用二段跳 //重置惯性 //role.moveProc.ResetInertia(); role.moveProc.ResetTurnLoss(); //记录滑落方向 role.moveProc.lastSlideVector = role.slideProc.slideVector; _JumpInTheSky(jumpSpeed, true); } //注意:onIceGround此处属于特殊情况。。。。 } } }
// Update is called once per frame void Update() { BeforeUpdate(); if (isFloating == false) { moveProc.UpdateByParent(); jumpProc.UpdateByParent(); } //处理既下落又滑落的情况。 bool hasFall = false; bool hasSlide = false; Vector3 posBegin; posBegin = transform.position; //下落 if (fallProc.isActiveAndEnabled && isFloating == false) { fallProc.UpdateByParent(); if (transform.position != posBegin) { hasFall = true; } } Vector3 posMid = transform.position; //滑落 if (slideProc.isActiveAndEnabled) { slideProc.UpdateByParent(); if (transform.position != posMid) { hasSlide = true; } } Vector3 posEnd = transform.position; if (hasFall && hasSlide && groundDct.IsOnIceground()) { transform.position = Vector3.Lerp(posBegin, posEnd, 0.7f); } groundDct.UpdateByParent(); }