Fix bug with Pulver not returning to his usual movement after item pickup
This commit is contained in:
@@ -335,28 +335,19 @@ public class FollowerController: MonoBehaviour
|
||||
}
|
||||
OnPickupArrived?.Invoke();
|
||||
|
||||
// Wait briefly, then return to player
|
||||
// Brief pause at the item before returning
|
||||
yield return new WaitForSeconds(_interactionSettings.FollowerPickupDelay);
|
||||
if (_aiPath != null && playerTransform != null)
|
||||
{
|
||||
_aiPath.maxSpeed = _followerMaxSpeed;
|
||||
_aiPath.destination = playerTransform.position;
|
||||
}
|
||||
_isReturningToPlayer = true;
|
||||
// Wait until follower returns to player (2D distance)
|
||||
while (playerTransform != null && Vector2.Distance(new Vector2(transform.position.x, transform.position.y), new Vector2(playerTransform.position.x, playerTransform.position.y)) > _settings.StopThreshold)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
_isReturningToPlayer = false;
|
||||
OnPickupReturned?.Invoke();
|
||||
|
||||
// Reset follower speed to normal after pickup
|
||||
_followerMaxSpeed = _defaultFollowerMaxSpeed;
|
||||
if (_aiPath != null)
|
||||
_aiPath.maxSpeed = _followerMaxSpeed;
|
||||
|
||||
// Immediately resume normal following behavior
|
||||
_isManualFollowing = true;
|
||||
if (_aiPath != null)
|
||||
_aiPath.enabled = false;
|
||||
|
||||
_pickupCoroutine = null;
|
||||
}
|
||||
|
||||
@@ -382,6 +373,16 @@ public class FollowerController: MonoBehaviour
|
||||
// Signal arrival
|
||||
OnPickupArrived?.Invoke();
|
||||
|
||||
// Reset follower speed to normal after reaching the point
|
||||
_followerMaxSpeed = _defaultFollowerMaxSpeed;
|
||||
if (_aiPath != null)
|
||||
_aiPath.maxSpeed = _followerMaxSpeed;
|
||||
|
||||
// Immediately resume normal following behavior
|
||||
_isManualFollowing = true;
|
||||
if (_aiPath != null)
|
||||
_aiPath.enabled = false;
|
||||
|
||||
_pickupCoroutine = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user