private void FixedUpdate() { if (currentState == WallRunState.none) //if not wallrunning, check if started wallrunning { if (stateMachine.playerState.ToString().Contains("LEFT")) { currentState = WallRunState.left; metalSystemLeft.emissionRate = emissionRate; //leftEffect.enabled = true; } else if (stateMachine.playerState.ToString().Contains("RIGHT")) { currentState = WallRunState.right; metalSystemRight.emissionRate = emissionRate; //rightEffect.enabled = true; } } else //if wallrunning, check if stopped walrunning { if (!stateMachine.playerState.ToString().Contains("WALLRUN")) { currentState = WallRunState.none; metalSystemLeft.emissionRate = 0; metalSystemRight.emissionRate = 0; //leftEffect.enabled = false; //rightEffect.enabled = false; } } }
/// <summary> /// プレイヤーから左右に壁がないか探す /// </summary> private void WallCheck() { if (wallRanIntervalFlag) { if (rightKeyFlag) { Ray rightRay = new Ray(transform.position, transform.right); RaycastHit rightHit; Debug.DrawRay(rightRay.origin, rightRay.direction * wallCheckDistance); if (Physics.Raycast(rightRay, out rightHit, wallCheckDistance, layer)) { playereState = PlayereState.WallRun; wallRunState = WallRunState.Right; } } if (leftKeyFlag) { Ray leftRay = new Ray(transform.position, transform.right * -1); RaycastHit leftHit; Debug.DrawRay(leftRay.origin, leftRay.direction * wallCheckDistance); if (Physics.Raycast(leftRay, out leftHit, wallCheckDistance, layer)) { playereState = PlayereState.WallRun; wallRunState = WallRunState.Left; } } } }
void onStateChanged(CharacterStateBase newState, CharacterStateBase prevState) { if (typeof(InAirState).IsAssignableFrom(prevState.GetType()) && typeof(GroundState).IsAssignableFrom(newState.GetType())) { InAirState inAirState = (InAirState)prevState; if (Mathf.Abs(inAirState.LastInAirVelocity.y) > minYVelocityToAnimateLanding) { headAnimationController.AnimateLand(); } } if (typeof(WallRunState).IsAssignableFrom(newState.GetType())) { WallRunState wallRunState = (WallRunState)newState; switch (wallRunState.WallRunSide) { case WallRunState.WallRunType.LEFT: spineAnimationController.AnimateWallRunLeft(); break; case WallRunState.WallRunType.RIGH: spineAnimationController.AnimateWallRunRight(); break; } } if (typeof(WallRunState).IsAssignableFrom(prevState.GetType())) { spineAnimationController.AnimateToDefaultPosition(); } else if (typeof(GroundState).IsAssignableFrom(newState.GetType())) { GroundState groundState = (GroundState)newState; onGroundStateInternalStateChaged(groundState.InternalState); } else if (typeof(SlideState).IsAssignableFrom(newState.GetType())) { headAnimationController.SetCrouch(true); } }