Skip to main content

Configure a complex Pickup

CompSpawnHelper allows an item whose VRCPickup or Return-detection Collider is on a child GameObject to be spawned and returned by its root.

Example structure​

ComplexItemRoot
├─ PickupObject
│ ├─ VRCPickup
│ ├─ Rigidbody
│ └─ Collider
└─ Other child GameObjects

Hierarchy of an item whose Pickup is on a child GameObject

In this example, register ComplexItemRoot in VRCObjectPool and add CompSpawnHelper to the same GameObject.

1. Configure the root registered in the Pool​

  1. Prepare a root GameObject that contains the entire item
  2. Add CompSpawnHelper to the root
  3. In Return Base Go, assign the child GameObject that enters the Return trigger
  4. Register the root GameObject in the Pool array of VRCObjectPool

Inspector showing Return Base Go configured on CompSpawnHelper

Roles of the root and Return Base Go

The parent root GameObject that contains the entire item is registered in VRCObjectPool and contains CompSpawnHelper.

Assign the Pickup-side child GameObject that enters the Return trigger to Return Base Go. This GameObject moves to the destination after Spawn and has its position and rotation reset after Return.

GameObject registered in the Pool

SpawnObjectExt obtains CompSpawnHelper from the spawned root GameObject. Add CompSpawnHelper to the same GameObject registered in VRCObjectPool.

2. Configure the Pickup and layer​

  1. Add VRCPickup, Rigidbody, and a Collider to the child GameObject
  2. Assign the Object Spawn Extension dedicated layer to the GameObject containing the Collider used for Return detection
  3. Set Layer on ReturnObjectExt to the same layer number
  4. Ensure that Pools on ReturnObjectExt can reference the VRCObjectPool containing the root

When the child Pickup enters the Return trigger, ReturnObjectExt searches its parents for CompSpawnHelper and hides the root GameObject containing that helper.

3. Check the movement method​

If Return Base Go contains VRCObjectSync, the helper uses synchronized movement and Respawn. Without VRCObjectSync, it saves the position and rotation at world startup and restores that Transform on Return.

Move Delay is the number of seconds to wait between spawning and moving the helper target. Normally use the default value, and increase it gradually if movement is not applied correctly.

Return Base Go is also a search target for SpawnOffset or an ObonEasy TrayItem component. To adjust the spawn position and orientation, see Adjust position and rotation when spawning.

Test the behavior​

  1. Spawn the item with SpawnObjectExt
  2. Confirm that the child GameObject assigned to Return Base Go moves to the specified spawn point
  3. Place the child Pickup in the Return trigger
  4. Confirm that the Pickup is dropped and the entire root registered in the Pool becomes hidden
  5. Spawn it again and confirm that it can be used in its initial state