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:
// 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);
}