namespace Sandbox; public partial class SoundHandle { /// /// Update our position every frame relative to our parent /// public bool FollowParent { get; set; } /// /// If we're following a parent, our position will be this relative to them. /// public Transform LocalTransform { get; set; } /// /// If set with a parent and is true, we will update our position to match the parent's world position. You can use to set an offset from the parent's position. /// Setting a parent also allows you to use GameObject.StopAllSounds on the parent to stop all sounds that are following it. /// This is set automatically when calling on a GameObject, but you can set it manually if you want to change the parent of an existing sound handle. /// public GameObject Parent { get; set; } void UpdateFollower() { if ( !FollowParent ) return; if ( !Parent.IsValid() ) { Parent = default; FollowParent = false; return; } var parentTx = Parent.WorldTransform; Transform = parentTx.ToWorld( LocalTransform ); } /// /// Clear our parent - stop following /// [Obsolete( "Just use Parent property directly" )] public void ClearParent() { Parent = default; } /// /// Tell the SoundHandle to follow this GameObject's position /// [Obsolete( "Just use Parent property directly" )] public void SetParent( GameObject obj ) { Parent = obj; } }