autotargetting fix

This commit is contained in:
2025-09-14 08:08:41 +02:00
parent fe6f768072
commit 7dab87f5ea
3 changed files with 27 additions and 28 deletions

View File

@@ -17140,7 +17140,7 @@ PrefabInstance:
- target: {fileID: 3749252306457878305, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -26.000061
value: -26.000122
objectReference: {fileID: 0}
- target: {fileID: 3806889720075550842, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
@@ -17547,6 +17547,16 @@ PrefabInstance:
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5054440825960491160, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: autoLockOnDistance
value: 2
objectReference: {fileID: 0}
- target: {fileID: 5054440825960491160, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: unlockDistanceThreshold
value: 3
objectReference: {fileID: 0}
- target: {fileID: 5083365752064418721, guid: 851e8e61247888340bdec90fc8aa37f5,
type: 3}
propertyPath: m_AnchorMax.x
@@ -19414,7 +19424,9 @@ MonoBehaviour:
m_sunLight: {fileID: 1976683114}
m_moonLight: {fileID: 0}
WeatherPresent: 0
WeatherSystem: {fileID: 0}
m_sunLightExists: 1
m_moonLightExists: 0
--- !u!4 &1013064392
Transform:
m_ObjectHideFlags: 10
@@ -22905,6 +22917,8 @@ MonoBehaviour:
x: 250
y: 250
z: 250
m_allFloatingPointFixMembers: []
m_allWorldSpaceParticleSystems: []
m_originTargetTileX: 0
m_originTargetTileZ: 0
m_terrainUnloadMemoryTreshold: 4294967296

View File

@@ -170,7 +170,6 @@ namespace Beyond
}
}
// REFACTORED: This method now has a clearer, more robust flow.
private void UpdateTarget()
{
if (_playerTransform == null || _gameStateManager == null || _manualSwitchCooldownActive) return;
@@ -206,7 +205,6 @@ namespace Beyond
UpdateLockOnState();
}
// NEW: This method exclusively handles the logic for locking on and off.
private void UpdateLockOnState()
{
if (targetLockSystem == null || _playerTransform == null) return;
@@ -217,7 +215,6 @@ namespace Beyond
{
float distanceToTarget = Vector3.Distance(_playerTransform.position, CurrentTarget.transform.position);
// This is a hysteresis check: use different distances for locking and unlocking to prevent flickering.
if (targetLockSystem.isLockingOn)
{
// If already locked, stay locked unless we are beyond the unlock threshold.
@@ -233,9 +230,9 @@ namespace Beyond
// Synchronize the desired state with the lock-on system.
Transform desiredLockTarget = shouldBeLocked ? CurrentTarget.transform : null;
// The lock-on system should be smart enough to not do anything if the target hasn't changed.
// We send the desired target (or null) every update.
targetLockSystem.ManuallySetLockOnTarget(desiredLockTarget, true);
// --- THIS IS THE FIX ---
// We now pass the 'shouldBeLocked' boolean to tell the system whether to lock or unlock.
targetLockSystem.ManuallySetLockOnTarget(desiredLockTarget, shouldBeLocked);
if (alwaysLockOnInCombat && desiredLockTarget != null && !targetLockSystem.isLockingOn)
{
@@ -243,7 +240,6 @@ namespace Beyond
}
}
// SIMPLIFIED: This method now only handles changing the CurrentTarget reference and its visual highlight.
private void SetNewTarget(vFSMBehaviourController newTarget, bool forceLockSystemUpdate = false)
{
if (CurrentTarget == newTarget) return;
@@ -309,9 +305,6 @@ namespace Beyond
if (targetLockSystem == null) return;
_manualSwitchCooldownActive = true;
_manualSwitchCooldownTimer = manualSwitchCooldownDuration;
// After manually unlocking, we let the main UpdateTarget loop find the next best candidate.
// If the previously locked target is still the closest, it will be re-highlighted automatically.
}
#endregion
@@ -347,23 +340,15 @@ namespace Beyond
public void ClearTarget(bool findNewOneImmediately)
{
// --- FIX APPLIED HERE ---
// 1. Explicitly tell the lock-on system to unlock immediately.
// This is the crucial step that resets the 'isLockingOn' flag to false.
if (targetLockSystem != null)
{
targetLockSystem.SetLockOn(false);
}
// 2. Deselect the current target and remove its highlight.
SetNewTarget(null);
// 3. If requested, immediately find a new target.
if (findNewOneImmediately && _gameStateManager != null && _gameStateManager.CurrentState == GameStateManager.State.COMBAT)
{
// Now, when UpdateTarget() runs, 'isLockingOn' will be correctly set to false,
// forcing the system to use the stricter 'autoLockOnDistance' for the new candidate.
if (!_manualSwitchCooldownActive)
{
UpdateTarget();

View File

@@ -849,7 +849,7 @@ PlayerSettings:
webWasm2023: 0
scriptingDefineSymbols:
: UNITY_POST_PROCESSING_STACK_V2
Android: UNITY_POST_PROCESSING_STACK_V2;CROSS_PLATFORM_INPUT;USE_TIMELINE;USE_NEW_INPUT;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER;TMP_PRESENT;ENEMIES_DISABLED
Android: UNITY_POST_PROCESSING_STACK_V2;CROSS_PLATFORM_INPUT;USE_TIMELINE;USE_NEW_INPUT;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER;TMP_PRESENT;ENEMIES_DISABLED;MOBILE_INPUT
CloudRendering: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
EmbeddedLinux: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
GameCoreScarlett: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
@@ -867,9 +867,9 @@ PlayerSettings:
Standalone: UNITY_POST_PROCESSING_STACK_V2;CROSS_PLATFORM_INPUT;INVECTOR_BASIC;INVECTOR_MELEE;TOUCH_REACT;GAIA_2_PRESENT;INVECTOR_AI_TEMPLATE;UPPipeline;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER;URP_OUTLINE;ODIN_INSPECTOR;ODIN_INSPECTOR_3;TMP_PRESENT;USE_TIMELINE;ODIN_INSPECTOR_3_1;ODIN_INSPECTOR_3_2;ODIN_INSPECTOR_3_3;ENEMIES_DISABLED
VisionOS: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
WebGL: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
Windows Store Apps: UNITY_POST_PROCESSING_STACK_V2;CROSS_PLATFORM_INPUT;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
Windows Store Apps: UNITY_POST_PROCESSING_STACK_V2;CROSS_PLATFORM_INPUT;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER;MOBILE_INPUT
XboxOne: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
iPhone: CROSS_PLATFORM_INPUT;INVECTOR_BASIC;INVECTOR_MELEE;GAIA_2_PRESENT;GAIA_PRO_PRESENT;UPPipeline;UNITY_POST_PROCESSING_STACK_V2;TOUCH_REACT;INVECTOR_AI_TEMPLATE;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER;URP_OUTLINE;ODIN_INSPECTOR;ODIN_INSPECTOR_3;TMP_PRESENT;USE_INVECTOR_INVENTORY;USE_TIMELINE;ODIN_INSPECTOR_3_1;ODIN_INSPECTOR_3_2;ODIN_INSPECTOR_3_3;ENEMIES_DISABLED
iPhone: CROSS_PLATFORM_INPUT;INVECTOR_BASIC;INVECTOR_MELEE;GAIA_2_PRESENT;GAIA_PRO_PRESENT;UPPipeline;UNITY_POST_PROCESSING_STACK_V2;TOUCH_REACT;INVECTOR_AI_TEMPLATE;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER;URP_OUTLINE;ODIN_INSPECTOR;ODIN_INSPECTOR_3;TMP_PRESENT;USE_INVECTOR_INVENTORY;USE_TIMELINE;ODIN_INSPECTOR_3_1;ODIN_INSPECTOR_3_2;ODIN_INSPECTOR_3_3;ENEMIES_DISABLED;MOBILE_INPUT
tvOS: UNITY_POST_PROCESSING_STACK_V2;PLAYMAKER;PLAYMAKER_1_9;PLAYMAKER_1_9_0;PLAYMAKER_1_8_OR_NEWER;PLAYMAKER_1_8_5_OR_NEWER;PLAYMAKER_1_9_OR_NEWER
additionalCompilerArguments: {}
platformArchitecture: {}