public override void UpdateState(PlayerPowerupScript owner) { _timer += Time.deltaTime; //_playerRB.velocity = new Vector2(_playerRB.velocity.x, -_dashSpeed); _player2D.OverrideVelocity(new Vector3(0f, -_dashSpeed, 0f)); //player2D.OverrideVelocity(new Vector3(player2D.previousVelocity.x, player2D.previousVelocity.y * _slowDownAmount, 0f)); if (_timer.Expired) { owner.powerupStateMachine.ChangeState(owner.defaultState); } }
private void OnCollisionEnter2D(Collision2D collision) { if (_playerLayers == (_playerLayers | 1 << collision.gameObject.layer)) { Player2D player2D = collision.gameObject.GetComponent <Player2D>(); if (Mathf.Abs(player2D.previousVelocity.y) > _velocityToBreak) { player2D.OverrideVelocity(new Vector3(player2D.previousVelocity.x, player2D.previousVelocity.y * _slowDownAmount, 0f)); Instantiate(_brokenBoardPrefab, transform.position, this.transform.rotation); GlobalState.state.AudioManager.FloorBreak(transform.position); GlobalState.state.Hitstop(_hitstopDuration); Destroy(this.gameObject); } } }