private void FixedUpdate() { if (_state == State.Down) { _time += Time.fixedDeltaTime; _mpMotor.position = new Vector3( _mpMotor.position.x, _moveDownFunc(_originalY + heightReached, _originalY, Mathf.Clamp01(_time / moveDownDuration)), transform.position.z); if (_time >= moveDownDuration) { _state = State.None; if (_player != null && _player.connectedPlatform == _mpMotor) { _state = State.Up; _time = 0; } else { _player = null; } } } if (_state == State.Up) { _time += Time.fixedDeltaTime; _mpMotor.position = new Vector3( _mpMotor.position.x, _moveUpFunc(_originalY, _originalY + heightReached, Mathf.Clamp01(_time / moveUpDuration)), transform.position.z); if (_time >= moveUpDuration) { _state = State.Down; _time = 0; if (_player.connectedPlatform == _mpMotor) { _player.DisconnectFromPlatform(); _player.velocity += Vector2.up * playerSpeedYAtApex; _player = null; } } } }