Working on ghost issues

This commit is contained in:
2026-01-24 16:23:53 +01:00
parent 1433b9bdfc
commit 912be35172
5 changed files with 980 additions and 975 deletions

View File

@@ -163,14 +163,15 @@ namespace Marro.PacManUdon
SetPosition(nextPosition);
}
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
{
if (turnAroundSoon && ghostState == PacManGhostState.Normal
&& GridMoverTools.CrossesTileBorder(position, nextPosition, direction.x != 0, direction.y != 0))
{
// Debug.Log($"{gameObject} turned around");
SetDirection(direction * -1);
Debug.Log($"{gameObject} turned around to direction {GetDirection()}");
turnAroundSoon = false;
return GridMoverTools.PositionToGrid(nextPosition);
}
if (kinematic)
@@ -232,6 +233,12 @@ namespace Marro.PacManUdon
// Debug.Log($"{gameObject} crossed tile center {gridPosition}, new target: {target}, new direction: {direction}");
}
var distance = Vector2.Distance(position, nextPosition);
if (distance > 0.5f)
{
Debug.LogError($"{gameObject} Just jumped by distance {distance}! position: {position}, nextPosition: {nextPosition}, direction: {direction}, offGrid: {offGrid}, ghostState: {ghostState}");
}
return nextPosition;
}