A lightweight component that, after a configurable delay, reparents one GameObject under another. It uses RealTimeSince to track elapsed time and calls Target.SetParent(NewParent, false) once.
using Sandbox;
namespace KOTH;
public sealed class BoneSwapperUtility : Component
{
[Property] public float Time { get; set; } = 0.5f;
public RealTimeSince TimeSinceStart { get; set; } = 0;
bool done = false;
[Property] public GameObject Target { get; set; }
[Property] public GameObject NewParent { get; set; }
protected override void OnUpdate()
{
if (TimeSinceStart > Time && !done)
{
done = true;
Target.SetParent(NewParent, false);
}
}
}