A component that listens for trigger enter events and activates a cage Rigidbody while playing a sound. It retrieves a Rigidbody component on start and, when OnTriggerEnter is called, plays the configured SoundEvent and enables the Rigidbody.
using Sandbox;
public sealed class CageDrop : Component, Component.ITriggerListener
{
[Property] public Rigidbody CageRB { get; set; }
[Property] public SoundEvent cagesound { get; set; }
void Start()
{
CageRB = Components.Get<Rigidbody>();
}
void ITriggerListener.OnTriggerEnter( Collider collision )
{
GameObject.PlaySound( cagesound );
CageRB.Enabled = true;
}
}