From 3db3ca277680829cf792cac24de7a97cafae8ec9 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 4 Oct 2025 16:57:32 -0400 Subject: [PATCH] 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 --- Assets/Scripts/Units/UnitMovementHandler.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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); }