public override void ComputeVelocity(PlayerPlatformController ppc, ref Vector2 velocity) { ppc.move = Vector2.zero; ppc.move.x = SwimmerInput.GetAxis("Horizontal"); if (SwimmerInput.GetButtonDown("Jump")) { velocity.y = ppc.jumpTakeOffSpeed; ppc.SetState(playerUnderwaterState); } else if (velocity.y < -0.01f) //if we've just walked off a ledge { ppc.SetState(playerUnderwaterState); } if (!isWalking && Mathf.Abs(ppc.move.x) > 0.01f) { Debug.Log("Broadcasting Walking-OnRiverbed Event!"); WalkingOnRiverbedEvent.Raise(); isWalking = !isWalking; } else if (isWalking && Mathf.Abs(ppc.move.x) < 0.01f) { Debug.Log("Broadcasting Standing Still on Riverbed Event!"); StillOnRiverbedEvent.Raise(); isWalking = !isWalking; } }
public override void ComputeVelocity(PlayerPlatformController ppc, ref Vector2 velocity) { ppc.move = Vector2.zero; ppc.move.x = SwimmerInput.GetAxis("Horizontal"); if (ppc.exhausted) { return; } if (SwimmerInput.GetButtonDown("Jump")) { Debug.Log("Jumping!"); velocity.y = ppc.jumpTakeOffSpeed; ppc.animator.SetTrigger("strokePerformed"); StrokeEvent.Raise(); AbovewaterStrokeEvent.Raise(); } if (ppc.headCollider.IsTouching(ppc.waterCollider)) { ppc.SetState(UnderwaterState); } if (ppc.FindCollision("Ledge")) { ppc.GetLedgeInfo(ppc.move); if (ppc.ledgeType == PlayerPlatformController.LEDGE.NONE) { return; } ppc.SetState(LedgeHangState); } }
public override void ComputeVelocity(PlayerPlatformController ppc, ref Vector2 velocity) { if (ppc.FindCollision("water")) { ppc.SetState(PlayerAbovewaterState); return; } ppc.move = Vector2.zero; ppc.move.x = SwimmerInput.GetAxis("Horizontal"); }