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

@@ -412,8 +412,16 @@ public partial class Game : Node3D, IGame
{
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
var restorative = restorativeScene.Instantiate<Restorative>();
AddChild(restorative);
restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
AddChild(restorative);
}
private void DropItem(Vector3 vector)
{
var randomItem = ItemDatabase.Instance.PickItem<IBaseInventoryItem>() as Node3D;
var duplicated = randomItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
duplicated.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
AddChild(duplicated);
}
private void UseTeleportPrompt_CloseTeleportPrompt()
@@ -691,7 +699,12 @@ public partial class Game : Node3D, IGame
private void GameRepo_EnemyDied(IEnemy obj)
{
DropRestorative(obj.GlobalPosition);
var rng = new RandomNumberGenerator();
rng.Randomize();
if (rng.Randf() < 0.15f)
DropItem(obj.GlobalPosition);
else
DropRestorative(obj.GlobalPosition);
}
private void BroadcastMessage(string obj)