public void AddImpulse(Vector3 addImpulse, bool canRedirect = false) { if (canRedirect) { impulseVelocityRedirectable += addImpulse; } else { impulseVelocity += addImpulse; } AddImpulseTrigger.Activate(); }
public override void Enter() { base.Enter(); playerController.UngroundMotor(); playerController.AddImpulseOverlayed(Vector3.up * JumpImpulse.Value); triggerJumpAnim.Activate(); }
public virtual void ActiveEndTrigger() { if (animEndedTrigger != null) { animEndedTrigger.Activate(); } }
void Awake() { this.enabled = true; #if UNITY_EDITOR if (ignoreInput) { return; } #endif playerMove = InputManager.Instance.GetPlayerMove_Action(); InputManager.Instance.onJump_Pressed += () => JumpPressed.Value = true; InputManager.Instance.onJump_Released += () => JumpPressed.Value = false; InputManager.Instance.onRoll_Pressed += () => RollPressed.Value = true; InputManager.Instance.onRoll_Released += () => RollPressed.Value = false; InputManager.Instance.onDash_Pressed += () => DashPressed.Value = true; InputManager.Instance.onDash_Released += () => DashPressed.Value = false; InputManager.Instance.onAttack_Pressed += () => AttackPressed.Value = true; InputManager.Instance.onAttack_Released += () => AttackPressed.Value = false; InputManager.Instance.onJump_Pressed += () => JumpTrigger.Activate(); InputManager.Instance.onAttack_Pressed += () => AttackTrigger.Activate(); InputManager.Instance.onAttack_Released += () => AttackReleaseTrigger.Activate(); InputManager.Instance.onDownwardAttack += () => DownwardAttackTrigger.Activate(); InputManager.Instance.onRoll_Pressed += () => RollTrigger.Activate(); InputManager.Instance.onRoll_Released += () => RollReleaseTrigger.Activate(); InputManager.Instance.onDash_Pressed += () => DashPressTrigger.Activate(); InputManager.Instance.onInteract += AttemptInspect; InputManager.Instance.onFunction3 += RemoveHunger; InputManager.Instance.onFunction4 += FeedHunger; freeLookCam = freeLookCamRef.Value.GetComponent <CinemachineFreeLook>(); }
public override void Enter() { base.Enter(); gravity = -(2 * maxJumpHeight.Value) / Mathf.Pow(timeToJumpApex.Value, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex.Value; playerController.UngroundMotor(); StoredJumpVelocity.Value = jumpVelocity + Mathf.Max(playerController.GetPlatformVelocity().y, 0f); triggerJumpAnim.Activate(); }
private void UpdateParameters() { IsGrounded.Value = charMotor.GroundingStatus.FoundAnyGround; IsOnSlidebleSlope.Value = StandingOnSlideableSlope(); BaseVelocity.Value = charMotor.BaseVelocity; groundInfo = GetGroundInfo(); DistanceToGround.Value = groundInfo.distance; GroundSlamCooldownTimer.UpdateTime(); if (!LastGroundingStatus.FoundAnyGround && GroundingStatus.FoundAnyGround) { BecameGrounded.Activate(); } else if (LastGroundingStatus.FoundAnyGround && !GroundingStatus.FoundAnyGround) { BecameUngrounded.Activate(); } }
private void CheckForFastTurn(Vector3 currentVelocity) { //Angle between move input of this frame and previous float deltaAngle_MoveInput = Vector3.Angle(MoveInput.Value.normalized, lastMoveInputDirection); bool noTurn = (!IsFastTurning.Value && !IsSlideTurning.Value); //Dont fast turn if angle change is gradual (meaning they r rotating stick instead of flicking) //If already fast turning, dont check this if (noTurn && deltaAngle_MoveInput < MoveInputRequiredDelta.Value) { return; } //If threshold is >=1 then set to infinity and disable threshold float FastTurnThreshold = (FastTurnPercentThreshold.Value >= 1f) ? Mathf.Infinity : FastTurnPercentThreshold.Value * MoveSpeed.Value; Vector2 horizontalVelocity = currentVelocity.xz(); //Dont start fast turn if moving too fast (instead will probably brake) if ((noTurn) && horizontalVelocity.magnitude > FastTurnThreshold) { return; } //Angle between flattened current speed and flattened desired move direction float deltaAngle_VelToMoveDir = Vector3.Angle(currentVelocity.xoz().normalized, moveInputCameraRelative.normalized); //Start fast turn if angle > ThreshHold and input magnitude > DeadZone if (noTurn && deltaAngle_VelToMoveDir > FastTurnAngleThreshold.Value && MoveInput.Value.magnitude > FastTurnInputDeadZone.Value) { if (horizontalVelocity.magnitude > SlideTurnThresholdSpeed.Value) { IsSlideTurning.Value = true; SlideTurnTriggered.Activate(); } else { IsFastTurning.Value = true; FastTurnTriggered.Activate(); } fastTurnStartDir = currentVelocity.xoz().normalized; } //Stop fast turning when close enough to target else if ((IsFastTurning.Value || IsSlideTurning.Value) && deltaAngle_VelToMoveDir < StopFastTurnDeltaAngle.Value) { IsFastTurning.Value = false; IsSlideTurning.Value = false; } }
private void CheckForHit(System.Object prevCollisionInfoObj, System.Object collisionInfoObj) { CollisionInfo collisionInfo = (CollisionInfo)collisionInfoObj; GameObject otherObj = collisionInfo.other.gameObject; if (otherObj.layer == LayerMapper.GetLayer(LayerEnum.Enemy)) { playerController.UngroundMotor(); Vector3 playerToTarget = (otherObj.transform.position.xoz() - playerController.transform.position.xoz()).normalized; //Vector3 knockbackDir = Vector3.RotateTowards(-playerToTarget, Vector3.up, 30f, 0f); KnockbackForceOutput.Value = -NewVelocityOut.Value.normalized.xoz() * KnockbackForceMagnitude.Value + Vector3.up * KnockbackForceMagnitude.Value; MeateorStrikeHitPosition.Value = collisionInfo.contactPoint; MeateorCollideTrigger.Activate(); MeateorStrikeCollision.Raise(collisionInfo); MeateorStrikeHitEvent.Raise(); } else { //If going fast enough into the normal, deflect with knockback Vector3 velocityIntoNormal = Vector3.Project(previousVelocityOutput, -collisionInfo.contactNormal); float velocityGroundDot = Vector3.Dot(previousVelocityOutput.normalized, collisionInfo.contactNormal); if (EnableDeflect && velocityIntoNormal.magnitude >= DeflectThresholdVelocity.Value && -velocityGroundDot > DeflectContactDotThreshold.Value) { playerController.UngroundMotor(); KnockbackForceOutput.Value = -NewVelocityOut.Value.normalized.xoz() * KnockbackForceMagnitude.Value + Vector3.up * KnockbackForceMagnitude.Value; MeateorStrikeHitPosition.Value = collisionInfo.contactPoint; MeateorCollideTrigger.Activate(); MeateorStrikeHitEvent.Raise(); } } }
private void Release() { float timeToOptimalCharge = Mathf.Abs(Time.time - (enterTime + OptimalChargeTime.Value)); if (timeToOptimalCharge < OptimalChargeErrorThreshold.Value) { accumulatedForce = MaxForce.Value * OptimalChargeMultiplier.Value * accumulatedForce.normalized; SlingShotOptimalReleaseEvent.Raise(); SlingShotOptimalReleaseTrigger.Activate(); } else if (accumulatedForce != Vector3.zero) { SlingShotReleaseEvent.Raise(); SlingShotReleaseTrigger.Activate(); } playerController.AddImpulse(accumulatedForce); playerController.ToggleArrow(false); DelayTimer.StartTimer(); }
private void AttemptJumpAttack(Collider otherCollider) { float playerBottomY = collider.bounds.center.y - collider.bounds.extents.y; float otherColliderBottomY = otherCollider.bounds.center.y - otherCollider.bounds.extents.y; //Only jump attack if player is above bottom of trigger and falling downwards if (playerBottomY > otherColliderBottomY && NewVelocity.Value.y <= 0f) { InteractionReceiver interactionReceiver = otherCollider.GetComponent <InteractionReceiver>(); if (interactionReceiver != null) { bool hasJumpInteraction = interactionReceiver.ReceiveJumpOnInteraction(new JumpOnPayload()); if (!hasJumpInteraction) { return; } } JumpAttackTrigger.Activate(); CameraShakeManager.Instance.ShakeCamera(1.75f, .3f, .3f); EffectsManager.Instance?.PlayClipAtPoint(jumpAttackClip, transform.position, .4f); } }