// PlayerEmoteControl.cs using Simuspaces.Simulation; public class PlayerEmoteControl : SimuScriptBase { public SceneObject ClickObject; public Emote selectedEmote; // "**" = every user in the scene via ForEachUser // "*" = only the user who clicked // anything else = exact username public string targetUsername = "**"; public bool highlightObject = true; public float interactDistance = 10f; bool playing; public override void Start() { if (ClickObject == null || ClickObject.IsNull) { Log("[PlayerEmoteControl] Slot a SceneObject into ClickObject first."); return; } MakeInteractable(ClickObject, OnClicked, highlightObject, null, true, interactDistance, "Toggle emote"); Log("[PlayerEmoteControl] Interactable registered on " + ClickObject.ObjectId); } void OnClicked(SVInteractionInfo info) { if (selectedEmote == null || selectedEmote.IsNull) { Log("[PlayerEmoteControl] Pick an emote from the selectedEmote dropdown first."); return; } string target = targetUsername; if (target == null || target.Trim() == "") target = "**"; target = target.Trim(); if (target == "*") { ToggleUser(info.Username); } else if (target == "**") { ForEachUser(user => ToggleUser(user.Username)); } else { ToggleUser(target); } playing = !playing; Log("[PlayerEmoteControl] target='" + target + "' emote='" + selectedEmote.InventoryId + "' playing=" + playing); } void ToggleUser(string username) { if (username == null || username.Trim() == "") return; if (playing) { StopPlayerEmote(username); } else { PlayPlayerEmote(username, selectedEmote); } } }