protected override void OnParentChanged( GameObject oldParent, GameObject newParent )
{
_ = MoveAfterwards();
}
// we need to wait so we're outside of OnParentChanged
async Task MoveAfterwards()
{
await Task.Yield();
// it's possible the owner changed during that time, so tell the current owner of the object to move it.
MoveIntoPosition();
}
[Rpc.Owner]
public void MoveIntoPosition()
{
WorldTransform = GameObject.Parent.WorldTransform;
}
You may not need the third level of indirection if you're not changing owner at the same time, so you can just put the movement directly after Task.Yield().