Skip to content

Commit 54be48e

Browse files
committed
fix(PickupsDropsChilds): Drop works for additive scenes
1 parent 8a6b579 commit 54be48e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Assets/Mirror/Examples/PickupsDropsChilds/Scripts/PickupsDropsChilds.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ void CmdDropItem()
187187
// Instantiate the scene object on the server
188188
Vector3 pos = rightHand.transform.position;
189189
Quaternion rot = rightHand.transform.rotation;
190-
equippedObject = Instantiate(sceneObjectPrefab, pos, rot);
190+
191+
// Instantiate the scene object initially parented to the player
192+
// transform so it's in the correct additive scene on server
193+
equippedObject = Instantiate(sceneObjectPrefab, pos, rot, transform);
194+
195+
// unparent the scene object immediately
196+
equippedObject.transform.SetParent(null);
191197

192198
// set the RigidBody as non-kinematic on the server only (isKinematic = true in prefab)
193199
equippedObject.GetComponent<Rigidbody>().isKinematic = false;

0 commit comments

Comments
 (0)