lockon, targetting and rolls control improvements

This commit is contained in:
2025-07-25 16:47:19 +02:00
parent f5c1c37d32
commit 630b9a7b53
6 changed files with 249 additions and 235 deletions

View File

@@ -165,7 +165,7 @@ namespace Beyond
}
else if (base.currentTarget == null && isLockingOn) // Target became null while we thought we were locked
{
UnlockTarget(false); // Silently unlock if target disappeared
UnlockTarget(false); // Silently unlock if target disappeared
}
}
@@ -394,5 +394,35 @@ namespace Beyond
if (Player.Instance != null) _playerTransform = Player.Instance.transform;
else _playerTransform = transform; // Fallback if bLockOn is on player
}
// --- ADD THIS ENTIRE METHOD TO YOUR bLockOn.cs SCRIPT ---
/// <summary>
/// Externally sets the lock-on state.
/// </summary>
/// <param name="value">True to turn lock-on ON, False to turn it OFF.</param>
public void SetLockOn(bool value)
{
// If the state is already what we want, do nothing.
if (isLockingOn == value)
{
return;
}
// We don't set isLockingOn directly here, as the methods below handle the state change.
if (value)
{
// If we are turning lock-on ON, find the best target immediately.
// This prevents a delay before the first lock.
// The `null` argument tells it to find any valid target.
AttemptLockOn(null);
}
else
{
// If we are turning lock-on OFF, clear the current target.
UnlockTarget();
}
}
}
}