I have placed 6 collectibles in my map but I only want one of them to spawn randomly. I don’t want chances or anything, only that ONE will spawn for sure.
I was thinking that I could create an array with all the collectibles, create a random number from 1 to 6, get the collectible from the array that has that index and spawn it. However, I can’t seem to find documentation about the collectible device in the verse reference API. Where can I find it? Is this the best way to do it?
That’s a logical way to do it for sure. You can’t stop the spawn from the beginning, so I would just hide them. Here are the options you have:
collectible_object_device := class(creative_device_base):
# Signaled when the collectible item is collected.
# Sends the agent that collected the item.
CollectedEvent:listenable(agent) = external {}
# Makes the collectible visible.
Show<public>():void = external {}
# Makes the collectible invisible.
Hide<public>():void = external {}
# Immediately respawns the object for the instigating agent.
# This will be affected by the option *Consume If Collected By*.
Respawn<public>(Agent:agent):void = external {}
# Immediately respawns the object for all agents.
RespawnForAll<public>():void = external {}
# Teleports the `device` to the specified `Position` and `Rotation`.
TeleportTo<public>(Position:vector3, Rotation:rotation)<transacts><decides>:void = external {}
# Teleports the `device` to the specified location defined by `Transform`, also applies rotation and scale accordingly.
TeleportTo<public>(Transform:transform)<transacts><decides>:void = external {}