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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user