Fix item removed being called one too many times, fix Pulver movement

This commit is contained in:
Michal Pikulski
2025-09-12 13:14:17 +02:00
parent d62516f0cb
commit 9a12a79698
3 changed files with 36 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ public class FollowerController: MonoBehaviour
/// </summary>
public float manualMoveSmooth = 8f;
private GameObject _playerRef;
private Transform _playerTransform;
private AIPath _playerAIPath;
private AIPath _aiPath;
@@ -59,6 +60,8 @@ public class FollowerController: MonoBehaviour
public event FollowerPickupHandler OnPickupReturned;
private Coroutine _pickupCoroutine;
private Input.PlayerTouchController _playerTouchController;
void Awake()
{
_aiPath = GetComponent<AIPath>();
@@ -183,8 +186,10 @@ public class FollowerController: MonoBehaviour
GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
if (playerObj != null)
{
_playerRef = playerObj;
_playerTransform = playerObj.transform;
_playerAIPath = playerObj.GetComponent<AIPath>();
_playerTouchController = playerObj.GetComponent<Input.PlayerTouchController>();
if (_playerAIPath != null)
{
_playerMaxSpeed = _playerAIPath.maxSpeed;
@@ -196,6 +201,7 @@ public class FollowerController: MonoBehaviour
{
_playerTransform = null;
_playerAIPath = null;
_playerTouchController = null;
}
}
@@ -222,6 +228,11 @@ public class FollowerController: MonoBehaviour
moveDir = _playerAIPath.velocity.normalized;
_lastMoveDir = moveDir;
}
else if (_playerTouchController != null && _playerTouchController.isHolding && _playerTouchController.LastDirectMoveDir.sqrMagnitude > 0.01f)
{
moveDir = _playerTouchController.LastDirectMoveDir;
_lastMoveDir = moveDir;
}
else
{
moveDir = _lastMoveDir;