void OnUngrab(uint sender, IValue[] args) { // Calculate current world coordinate of this object Vec worldPos; Quat worldRot; if (!obj.CalcWorldCoord(out worldPos, out worldRot)) { // When world coordinate calculation failed worldPos = new Vec(); worldRot = new Quat(); } // Become a child of World Object // TODO: more consideration about hierarchy (e.g. restore parent). probably as an option. obj.SetField("parent", node.Objects[SyncNode.WorldObjectId].GetObjectRef()); // Keep current world coordinate obj.SetField("position", worldPos); obj.SetField("rotation", worldRot); obj.WriteDebugLog("grabbable", $"Ungrabbed by object {sender}"); }