change: player facing direction is now forced to "static" from "towardstarget" if there is no target. player always rotates towards target instead of only when moving

This commit is contained in:
Chris
2025-10-04 16:57:32 -04:00
parent de460d9f0a
commit 3db3ca2776

View File

@@ -143,7 +143,10 @@ namespace Reset.Units{
case PlayerFacingDirection.TowardsTarget: case PlayerFacingDirection.TowardsTarget:
// Look directly at the target // Look directly at the target
if (lockOnManager.mainTarget == null) { 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; targetRotation = transform.rotation;
break; break;
} }
@@ -175,9 +178,9 @@ namespace Reset.Units{
DebugOverlayDrawer.ChangeValue("Rotation", "Target Rotation", targetRotation.eulerAngles); DebugOverlayDrawer.ChangeValue("Rotation", "Target Rotation", targetRotation.eulerAngles);
// Add the current input into the created rotation // 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; resolvedMovement.rotation = targetRotation;
} else if (data.facingDirection.Value == PlayerFacingDirection.MatchCamera) { } else if (controls.rawMoveInput.sqrMagnitude > .1){
resolvedMovement.rotation = targetRotation; resolvedMovement.rotation = targetRotation;
} }