codeAPI Reference

s&box BasePickup: Trigger and collision-based pickup system

calendar_today May 12, 2026 schedule ~2 min read person patrickjr verified 50

BasePickup API Reference

BasePickup is an abstract Component for creating trigger or collision-based pickups (weapons, ammo, items).

Type Signature

CSHARP
public abstract class BasePickup : Component, Component.ITriggerListener, Component.ICollisionListener

Required Component

CSHARP
[RequireComponent] public Collider Collider { get; set; }

Properties

Virtual Methods

Interface Implementations

ITriggerListener.OnTriggerEnter

Called when a GameObject enters the trigger collider. Checks for Player component and calls CanPickup/OnPickup.

ICollisionListener.OnCollisionStart

Called when a collision occurs. Similar to trigger but uses collision detection. Useful for pickups that should physically collide.

RPC Method

CSHARP
[Rpc.Broadcast]
protected void PlayPickupEffects(Player player)
Plays the pickup sound. Sets SpacialBlend to 0 for the local player (2D sound).

Notes

  • Both trigger and collision listeners are implemented - use whichever fits your pickup type.
  • Host-only logic (Networking.IsHost check) ensures pickups only process on the server.
  • DestroyGameObject() is called after successful pickup by default (return true from OnPickup).
Was this helpful?