public override void OnExcuteWithEvent(MovementFsm fsm) { //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Right); //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Left); if (!fsm.boxRayCaster.Down.CheckCollision(fsm.onGroundLayer)) { fsm.ChangeState(InAirStateWithEvent.Instance); return; } }
public override void OnExcuteWithEvent(MovementFsm fsm) { fsm.Velocity = fsm.Velocity + Vector2.down * fsm.yGravityForce * fsm.UpdateTime; if (Mathf.Abs(fsm.Velocity.y) > fsm.yMaxSpeed) { fsm.Velocity = new Vector2(fsm.Velocity.x, Mathf.Sign(fsm.Velocity.y) * fsm.yMaxSpeed); } //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Right); //fsm.ProcessCollisionBacktrack(fsm.boxRayCaster.Left); if (fsm.boxRayCaster.Down.CheckCollision(fsm.onGroundLayer)) { fsm.ChangeState(OnGroundStateWithEvent.Instance); fsm.Backtrack(fsm.boxRayCaster.Down); } }
public override void OnExcuteWithEvent(MovementFsm fsm) { float velocityY = fsm.Velocity.y; velocityY += fsm.yUpForceInGround * fsm.UpdateTime; velocityY = Mathf.Clamp(velocityY, -fsm.yMaxSpeedInGroundDown, fsm.yMaxSpeedInGroundUp); fsm.Velocity = new Vector2(fsm.Velocity.x, velocityY); if (!fsm.boxRayCaster.Down.CheckCollision(fsm.onGroundLayer)) { //var result = new List<BoxRayCaster.RayTrigger>(fsm.boxRayCaster.CheckCollision(fsm.onGroundLayer)); //if(result.Count == 0) { //Debug.Log(fsm.boxRayCaster.Down.CollisionStatus); //Debug.Break(); fsm.Velocity = new Vector2(fsm.Velocity.x, fsm.yDigJumpSpeed); fsm.ChangeState(InAirStateWithEvent.Instance); } }