[Player][Interactions] Refactor common settings to be in the Game Settings SO. Update follow paramters and pathfinding for Pulver

This commit is contained in:
Michal Pikulski
2025-09-04 11:12:19 +02:00
parent 65d8be6cf2
commit 5d395ba4f4
8 changed files with 185 additions and 103 deletions

View File

@@ -8,10 +8,6 @@ using Pathfinding; // Add this at the top
// Attach to the player GameObject. Works with or without Rigidbody/Rigidbody2D.
public class PlayerTouchController : MonoBehaviour, ITouchInputConsumer
{
public float moveSpeed = 5f;
public float stopDistance = 0.1f;
public bool useRigidbody = true;
Vector3 targetPosition;
bool hasTarget = false;
@@ -81,6 +77,7 @@ public class PlayerTouchController : MonoBehaviour, ITouchInputConsumer
if (aiPath != null)
{
aiPath.destination = targetPosition;
aiPath.maxSpeed = GameManager.Instance.MoveSpeed;
Debug.Log($"AIPath destination set to {targetPosition}");
}
else
@@ -124,14 +121,14 @@ public class PlayerTouchController : MonoBehaviour, ITouchInputConsumer
if (aiPath != null)
{
aiPath.destination = target;
aiPath.maxSpeed = GameManager.Instance.MoveSpeed;
}
while (!interruptMoveTo)
{
// 2D distance calculation (ignore z)
Vector2 current2D = new Vector2(transform.position.x, transform.position.y);
Vector2 target2D = new Vector2(target.x, target.y);
float dist = Vector2.Distance(current2D, target2D);
if (dist <= stopDistance + 0.2f)
if (dist <= GameManager.Instance.StopDistance + 0.2f)
{
break;
}