Skip to content

Commit

Permalink
Fix a bug where actor might spawn at wrong Y position
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Jul 6, 2023
1 parent b1add2a commit 3f46794
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/Scripts/Pal3/Actor/ActorMovementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,19 @@ public void Init(Actor actor, Tilemap tilemap, ActorActionController actionContr
actor.Info.GameBoxYPosition,
actor.Info.GameBoxZPosition));

// Setup actor's initial position
if (actor.Info.InitBehaviour != ScnActorBehaviour.Hold &&
_tilemap.TryGetTile(initPosition, _currentLayerIndex, out NavTile tile))
{
if (tile.IsWalkable())
// If the actor is initially placed on a walkable tile, snap to the tile
// Same for the case when actor is configured to not facing the player actor during dialogue
if (tile.IsWalkable() || actor.Info.NoTurn == 1)
{
transform.position = new Vector3(initPosition.x,
GameBoxInterpreter.ToUnityYPosition(tile.GameBoxYPosition),
initPosition.z);
}
else
else // This is to handle the case where the actor is initially placed on a non-walkable tile
{
Vector2Int tilePosition = _tilemap.GetTilePosition(initPosition, _currentLayerIndex);
// Snap to the nearest adjacent tile if exists
Expand Down

0 comments on commit 3f46794

Please sign in to comment.