diff --git a/Assets/Scripts/Units/UnitMovementHandler.cs b/Assets/Scripts/Units/UnitMovementHandler.cs index 280b04f..30e8658 100644 --- a/Assets/Scripts/Units/UnitMovementHandler.cs +++ b/Assets/Scripts/Units/UnitMovementHandler.cs @@ -143,7 +143,10 @@ namespace Reset.Units{ case PlayerFacingDirection.TowardsTarget: // Look directly at the target if (lockOnManager.mainTarget == null) { - Debug.LogError("Trying to rotate towards a target but there is no target. Not setting a rotation"); + Debug.LogError("Trying to rotate towards a target but there is no target. Forcing rotation to Static and continuing"); + data.facingDirection.Value = PlayerFacingDirection.Static; + data.facingDirection.currentValue = PlayerFacingDirection.Static; + targetRotation = transform.rotation; break; } @@ -175,12 +178,12 @@ namespace Reset.Units{ DebugOverlayDrawer.ChangeValue("Rotation", "Target Rotation", targetRotation.eulerAngles); // Add the current input into the created rotation - if (inputMovement.magnitude > .05) { + if (data.facingDirection.Value == PlayerFacingDirection.MatchCamera || data.facingDirection.Value == PlayerFacingDirection.TowardsTarget) { resolvedMovement.rotation = targetRotation; - } else if (data.facingDirection.Value == PlayerFacingDirection.MatchCamera) { + } else if (controls.rawMoveInput.sqrMagnitude > .1){ resolvedMovement.rotation = targetRotation; } - + // Apply rotation to the character transform.rotation = Quaternion.Slerp(transform.rotation, resolvedMovement.rotation, data.rotationSpeed.Value * Time.deltaTime).Flatten(0, null, 0); }