Jump to content
TailBlue

Playing Sound in Child Prims from Root prim

Recommended Posts

I build spaceship meshes and Ive made an interior kit for the ship with doors and all. On all of the doors I use a main controller script in the root prim that uses Fast Pramerters and the description and name of the child prims inside the linkset. So ONLY the door meshes are named Door will open or close if touched in the linkset. How ever I ran into an issue thinking of a way to play a single door sound from the root prim to the child prims. I dont want to have to put a single script inside each door 16 in total to play sound when the doors are touched and open. So im wondering if there is a way to do this? My scripter tells me there isnt such a command but ive been looking into it and just curios if there was any way of doing it. I want the sound to play local from the door it self NOT the root prim, because honestly that kinda ruins the immersion of the ship if i open a door and the sound plays in the back of the ship where the root is.

Thanks

Share this post


Link to post
Share on other sites

The llPlaySound and llTriggerSound commands create a sound emitter in the prim that the script is in.  There's no way to create a remote sound generator other than to put a short slave script in each of the doors and trigger them individually from the root.  I realize that sounds inefficient, but sometimes that's what's necessary.  A small script that is going to be idle almost all the time will not use much of the sim's memory and will not create any measurable drain on total script time.

  • Like 1

Share this post


Link to post
Share on other sites

Kudos to you for trying to keep your script count low!

Sadly, there aren't any LSL linked functions available that allow a script to play/trigger sounds in a linked child prim. As it stands, playing/triggering sounds requires a dedicated script in the prim the sound is meant to emanate from. I know this feature has been requested a number of times on the JIRA, but they haven't gotten any traction it seems.

Having said that, I have an idea you might want to explore. What if you take one child prim which contains the necessary sound and activation script, and have it physically reposition itself at whatever door is currently being opened/closed. Essentially, your door controller's llSetPrimitiveParamsFast function call could include a parameter to move this child prim to the same local offset as the door and then immediately issue a linked message (or llRegionSayTo) to that child prim. The child prim in turn would listen for the linked message and when heard, play the appropriate sound effect.

The drawback to this workaround is that you're somewhat limited to one action at a time. The child prim must remain at its current location for as long as the sound is playing. As such, you would need additional synchronization logic in the door controller to wait for the child prim to be ready to service the next door opening/closing. I don't think it would be *too* complicated, but it would require a bit more work to coordinate over the more straightforward approach of having a small script in each door.

Edit: As Rolig points out, if you were to place scripts in the doors to handle the sounds, they would very likely be trivial and ave a minimal impact on the simulator. For bonus points, if you write these scripts to be generic enough such that they can be dropped into each of the doors without being recompiled, you would be in a position to take advantage of mono's bytecode sharing. So the door script would only have one instance of the code being shared among all the doors (not including the individual script state and stack content).

Edited by Fenix Eldritch
  • Like 2

Share this post


Link to post
Share on other sites

Thanks for your inputs,

I understand so there isnt any command as such like I thought >_< I could do the prim where it moves to the location of the doors opening but to me i think that would be little to much as this is a spaceship its being used on with tight quarters and all. Person walks through one door then a second later walking to the hangar etc. We did go with the other approach of having a slave script. It listens to a string from the controller script using  link_message for the sound UUID and plays that sound when the door opens. To my amazement its fairly low impact. So thats a plus! ^^  The controller script has all the code to open each door and the sound. Slave scripts are literally just 14 lines of sound listen and play.

Arigato to both of you for answering.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...