I am looking at adding a boombox to certain monuments like outpost and bandit camp. I have got the boombox spawning in and powering it. However, I can't figure out how to make it select the audio stream and playing it. Any suggestions?
Deployable Boombox
Which boombox prefab are you spawning and how are you spawning it?
var boombox = GameManager.server?.CreateEntity(BOOMBOX_PREFAB, entity.transform.position) as DeployableBoomBox;
if (boombox == null)
{
Puts("No deployable boombox found!");
return;
}
boombox.Spawn();
boombox.SetParent(entity);
boombox.transform.localPosition = new Vector3(0f, 0.85f, 1.75f);
boombox.SendNetworkUpdateImmediate(true);
// Provide power to the boombox
boombox.UpdateFromInput(25, 0);
I see, you're doing this all via code. Likely you want to look into the boom box controller, which is available under boombox.BoxController.
Also, this is a good idea for the Monument Addons plugin. It already allows you to spawn boomboxes at monuments, but maybe a feature can be added so that an admin can configure the boombox to have a preselected station and automatically be turned on.
Thanks. I got it working. Now it's falling off of heli or breaking or something.
boombox.BoxController.ConditionLossRate = 0;
// Turn off the current station
boombox.BoxController.ServerTogglePlay(false);
_CurrentRadioIp.SetValue(boombox.BoxController, "https://.../creedence-clearwater-revival-fortunate-son.mp3");
// Use newly select MP3 stream
boombox.BoxController.BaseEntity.ClientRPC<string>(
null,
"OnRadioIPChanged",
boombox.BoxController.CurrentRadioIp);
// Start playing again!
boombox.BoxController.ServerTogglePlay(true);
I recommend spawning the boombox.static prefab which avoids those problems. It neither breaks nor disappears.