Fix really really really annoying issue with enemy spawns

Godot refuses to set CharacterBody3D positions correctly unless you call ResetPhysicsInterpolation immediately after
This commit is contained in:
2026-03-01 17:54:34 -08:00
parent e50035d9c7
commit 840ffe1a9a
6 changed files with 23 additions and 9 deletions

View File

@@ -2,7 +2,6 @@ using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using System.Linq;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
@@ -41,8 +40,9 @@ public partial class MonsterRoom : DungeonRoom
var index = rng.RandWeighted([.. enemyInfo.Values]);
var selectedEnemy = enemyInfo.ElementAt((int)index);
var instantiatedEnemy = EnemyTypeToEnemyConverter.Convert(selectedEnemy.Key);
instantiatedEnemy.Position = new Vector3(spawnPoint.Position.X, 0f, spawnPoint.Position.Z);
AddChild(instantiatedEnemy);
instantiatedEnemy.GlobalPosition = new Vector3(spawnPoint.GlobalPosition.X, 0f, spawnPoint.GlobalPosition.Z);
ResetPhysicsInterpolation();
}
}
@@ -65,7 +65,7 @@ public partial class MonsterRoom : DungeonRoom
var selectedItem = database.PickItem<IBaseInventoryItem>() as Node3D;
var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
duplicated.Position = new Vector3(spawnPoint.Position.X, 0, spawnPoint.Position.Z);
duplicated.GlobalPosition = new Vector3(spawnPoint.GlobalPosition.X, 0, spawnPoint.GlobalPosition.Z);
AddChild(duplicated);
}
}