public Vector3 TabTargetGetMoveDirection(float horizontalInput, float verticalInput) { Vector3 moveDirection = Vector3.zero; if (CacheGameplayCamera) { switch (CurrentGameInstance.DimensionType) { case DimensionType.Dimension3D: Vector3 forward = CacheGameplayCamera.transform.forward; Vector3 right = CacheGameplayCamera.transform.right; MovementState movementState = PlayerCharacterEntity.MovementState; if (Targeting.SelectedTarget && Targeting.focusingTarget) { PlayerCharacterEntity.SetLookRotation(Quaternion.LookRotation(Targeting.SelectedTarget.transform.position - PlayerCharacterEntity.transform.position)); forward = PlayerCharacterEntity.transform.forward; right = PlayerCharacterEntity.transform.right; } SwimRigidBodyEntityMovement rigid; IVehicleEntity entity = PlayerCharacterEntity.PassengingVehicleEntity; GameObject movingObject = PlayerCharacterEntity.GetGameObject(); if (entity?.GetPassenger(0) == PlayerCharacterEntity) { movingObject = entity.GetGameObject(); } movingObject.TryGetComponent <SwimRigidBodyEntityMovement>(out rigid); if (rigid != null) { if (!rigid.IsUnderWater && !rigid.IsFlying) { forward.y = 0f; right.y = 0f; } else { if (InputManager.GetButton("Jump")) { moveDirection += Vector3.up; } else if (InputManager.GetButton("Crouch")) { moveDirection += Vector3.down; } } } forward.Normalize(); right.Normalize(); moveDirection += forward * verticalInput; moveDirection += right * horizontalInput; // normalize input if it exceeds 1 in combined length: if (moveDirection.sqrMagnitude > 1) { moveDirection.Normalize(); } break; case DimensionType.Dimension2D: moveDirection = new Vector2(horizontalInput, verticalInput); break; } } return(moveDirection); }