private void FixedUpdate() { if (_jumping) { Jump(); return; } var wasGrounded = Grounded; var size = Physics2D.OverlapCircleNonAlloc(groundCheck.position, GroundedRadius, _colliders, whatIsGround); for (var i = 0; i < size; i++) { if (_colliders[i].gameObject == gameObject) { continue; } Grounded = true; _currentJumps = 0; if (!wasGrounded) { OnLandEvent?.Invoke(); } return; } Grounded = false; }
private void HandleStateUpdate(bool wasRunningLastFrame) { //Register Wall Slide if (!_mover.IsGrounded) { if ((_mover.CollidedLeft && _goingLeft) || (_mover.CollidedRight && _goingRight)) { if (!state.isSliding) { _velocity.y = (_velocity.y > maxGravity * slideGravityDamping) ? _velocity.y : maxGravity * slideGravityDamping; } state.isSliding = true; } else if (!_mover.HasCollidedHorizontal && state.isSliding) { state.isSliding = false; } } else if (state.isSliding) { state.isSliding = false; } if (state.isReeling && _mover.HasCollidedHorizontal) { state.isReeling = false; state.gravityDisabled = false; } if (_mover.HasLanded) { state.ResetAbilityUsage(); state.isSliding = false; OnLandEvent?.Invoke(); } //run-event should be called in the frame that movement goes from 0 to not-zero, as well as any frame where the player lands while moving. //TODO: rework sound system. if ((!wasRunningLastFrame || _mover.HasLanded) && horizontalMove != 0 && _mover.IsGrounded && !_mover.HasCollidedHorizontal) { OnRunStartEvent?.Invoke(); } else if ((wasRunningLastFrame && horizontalMove == 0 && _mover.IsGrounded) || _mover.HasLeftGround || _mover.IsGrounded && _mover.HasCollidedHorizontal) { OnRunEndEvent?.Invoke(); } }
private void FixedUpdate() { bool wasGrounded = m_Grounded; //������ ���� ���� ���������� �Ǻ�, �� ���� ���̾����� �Ǻ� m_Grounded = false; // �ֺ��� Ȯ��, �� ���̾ �ִٸ� �� ��ȯ if (Physics2D.OverlapCircle(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround)) { m_Grounded = true; if (!wasGrounded) //�������̾��ٸ� idle ���·� �ٲ�� �ϹǷ� �̺�Ʈ invoke { OnLandEvent.Invoke(); } } }
public void OnLandEffect() { OnLandEvent?.Invoke(); }