Collision vs sensor
|
|
DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
|
04-20-2009 07:00
Hi there, I have built a tour on my sim and am working on adding narration. My plan is to place "objects" along the tour and when the tourists collide with them, they will trigger the narration. My understanding is that using collision events rather than repeating sensors uses fewer sim resources. Each tour vehicle carries up to 4 passengers. Here is the code I have so far: default { state_entry() { llVolumeDetect(TRUE); // Starts llVolumeDetect } collision_start(integer num) { integer i; while(i<num) { llParcelMediaCommandList([ PARCEL_MEDIA_COMMAND_TYPE, "audio/mpeg", PARCEL_MEDIA_COMMAND_AGENT, llDetectedKey(i), PARCEL_MEDIA_COMMAND_URL, "http://blah/blah/blah.mp3", PARCEL_MEDIA_COMMAND_PLAY]); llOwnerSay("contact"  ; ++i; } llSleep (30); llResetScript(); } } Here is my problem. When the tour vehicle is traveling fast, the collision event is triggered, as evidenced by the script correctly saying "contact", but I do not hear the mp3 file. If I slowly walk through the prim I do hear the audio correctly. I have tried using llSensorRepeat but as soon as the tour vehicle goes out of range, the audio stops. Plus, I'd like to avoid having too many sensors constantly scanning for tour vehicles. Any thoughts? What would be the best way to code something like this. Thanks, Doug
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
04-20-2009 08:21
Play the media in a prim on the bus instead. Collision event will send a message for the message to start.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-20-2009 08:44
the collision model is good, another possibility is that if your bus has a set route you could use llTarget with a large range to trigger the sounds (and then update and wait for the next target to be in range)
your sound problem will most easily be solved by Jesse's method, which will allow the sound to be preloaded and travel with the tour bus (sounds like load times are what's hurting you in the current method). coupled with llTarget and a predetermined route, all the code could be contained in the tour bus.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
04-20-2009 08:47
And I forgot to mention that this would also negate the doppler effect.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
|
04-20-2009 13:01
Yes, either preloading the sound beforehand with llPreloadSound or playing the sound from the tour bus will solve your problem.
_____________________
Life is a highway... And I just missed my exit.
|
|
DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
|
04-20-2009 14:09
From: Cypher Ragu Yes, either preloading the sound beforehand with llPreloadSound or playing the sound from the tour bus will solve your problem. Thanks Jesse, Void and Cypher. I'm not exactly sure how sounds work in SL so I don't know if it's a loading issue. The tour used to be run by pre-loading 10-second sound snippets and playing them along the way. That was very erratic and whether the correct sound file would play was a 50-50 proposition. That is what prompted me to use the parcel media approach. That seems to be much better and I have another tour (a much smaller tour) that uses sensors and parcel media and it seems to run just fine. I did learn that one of my problems was that, since this is a sim-wide tour, I was crossing some parcels that I had set up on the ground (this tour is up at 300 meters) and of course every time I left one parcel and entered another the sound stopped. D'OH  This tour is using the Guided Tour System and it allows for passing some commands so I have worked it out that the tour vehicle just says the appropriate sound file name at the appropriate time and the prim I scripted just listens on that channel for the command and then issues the parcel media command to play the appropriate file. The audio files are housed on our university streaming server so I would think it should be able to handle the bandwidth. I'm fussing a bit with getting the sound to play for everyone on the tour since without a collision event I have to re-think the llDetectedKey approach. It's a fun tour by the way - at least it will be once I get it fixed. It is a tour through the human testis for my undergraduate and medical students. Explains how sperm are produced. Thanks again for your help. Doug
|
|
DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
|
04-21-2009 08:47
From: DrDoug Pennell
I'm not exactly sure how sounds work in SL so I don't know if it's a loading issue. The tour used to be run by pre-loading 10-second sound snippets and playing them along the way. That was very erratic and whether the correct sound file would play was a 50-50 proposition. That is what prompted me to use the parcel media approach. That seems to be much better.
Well, I spoke too soon. Don't know if it's an SL thing but the new version is not much better than the old system. It seems to repeat audio files at random. Here is what I have done. The tour just says commands on the correct channel; $,say,245,testis3, which I'm assuming just gets converted into llSay (245, "testis3"  ; My code in the vehicle prim (seat) is: key whoami; default { state_entry() { llListen(245, "", "", ""  ; } touch_start(integer num) { integer i; while(i<num) { whoami == llDetectedKey(i); ++i; } } listen( integer channel, string name, key id, string message ) { llParcelMediaCommandList([ PARCEL_MEDIA_COMMAND_TYPE, "audio/mpeg", PARCEL_MEDIA_COMMAND_AGENT, whoami, PARCEL_MEDIA_COMMAND_URL, "http://streaming.osu.edu/mediaWWW/comph662Asp09/testisaudiofiles/"+message+".mp3", PARCEL_MEDIA_COMMAND_PLAY]); llOwnerSay("heard"+message+".mp3"  ;//to let me know what it heard } } I probably have the llDetectedKey part wrong but I need the audio to play for everyone on the tour. I'm guessing I will have to put this code in every seat. The strange thing is that the script ALWAYS says that it hears the correct file name, but it often plays the one it just finished playing. Is this a loading problem? Is there a way to preload audio files that are going to be played as parcel media? Thanks, Doug
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-21-2009 10:14
Is see two very bad things there
one you're trying to play the media through the parcel, and as you already realized, that cuts off at the parcel border (so do triggered sounds if you check "restrict spatialized sounds to this parcel (I think that's the label?)... so not what you were hoping to do...
the other very, Very, VERY bad thing is the unfiltered listen command... it doesn't check who's talking to it, what's being said, nothing.... it just slams whatever it hears into the parcel media, regardless of the source.
either filter by owner llListen( 245, "", llGetOwner(), "" ); or by owned BY at least if (llOwnerKey( id ) == llGetOwner){ //-- rest of the listen code }
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
|
04-21-2009 10:56
From: Void Singer Is see two very bad things there
one you're trying to play the media through the parcel, and as you already realized, that cuts off at the parcel border (so do triggered sounds if you check "restrict spatialized sounds to this parcel (I think that's the label?)... so not what you were hoping to do...
the other very, Very, VERY bad thing is the unfiltered listen command... it doesn't check who's talking to it, what's being said, nothing.... it just slams whatever it hears into the parcel media, regardless of the source.
either filter by owner llListen( 245, "", llGetOwner(), "" ); or by owned BY at least if (llOwnerKey( id ) == llGetOwner){ //-- rest of the listen code } Hi Void, Only two? Given my ptitful coding abilities, I'll take that as a compliment  . I am trying to play the audio through the parcel because I don't know of a better way to do it. Uploading little 10 second wav files and preloading and playing those did not work well at all, which is why I'm trying to find a better way. I deleted most of the offending parcel boundaries so that is no longer a problem. I make sure I stay on the same parcel until the audio file is complete. I changed the second thing so that it was only listening to me, but it was only listening on channel 245 anyway and the only thing spoken on that channel was these commands so I though it was OK. Would it work any better to somehow use the music url - llSetParcelMusicURL? Thanks again for all your help. Seems like this should be easier than it is (or I am making it). Doug
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-22-2009 00:45
unfortunately for your this sort of thing is always a mess.
expanding the parcel is just going to have everyone in the area hearing (IIRC it loops) actually streaming it probably won't help either.
regardless of what method you use, it got to get to the rider(s) computer(s) before it'll start playing, so it's never guaranteed to run simultaneously for anyone... even preloading 10 second chunks. the two benefits of the preload method are that you can preload in advance of getting to your loacation, AND you'll be able to play the clips directly in the bus, allowing the sound to follow the rider(s).
no matter how you do it, outside audio/visual media in SL tends to be a PITA.
you might be able to set a longer wait at each point of interest, or have it stop until the riders inform you they're ready to move on (via a button press or something) include a timeout so that one person that's busy doesn't hold up things too long
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
|
04-22-2009 05:56
From: Void Singer unfortunately for your this sort of thing is always a mess.
expanding the parcel is just going to have everyone in the area hearing (IIRC it loops) actually streaming it probably won't help either. Hi Void, I don't think is is correct. I'm pretty sure that as long as I use the PARCEL_MEDIA_COMMAND_AGENT, flag, that only the avatar who is sitting in the seat (or who has been detected by the sensor/collision) will hear the audio. That is how multiple people on the same parcel can watch different videos at the same time. On my other tour it only plays for those on the tour. If you are standing next to the tour vehicle on the same parcel (but out of sensor range) you do not hear the audio. From: Void Singer regardless of what method you use, it got to get to the rider(s) computer(s) before it'll start playing, so it's never guaranteed to run simultaneously for anyone... even preloading 10 second chunks. the two benefits of the preload method are that you can preload in advance of getting to your loacation, AND you'll be able to play the clips directly in the bus, allowing the sound to follow the rider(s). I just wish that method worked reliably. Even with pre-loading the sounds, it rarely if ever plays them all correctly. I think that with the parcel media route the audio stays with the riders, as long as they don't leave the parcel before the clip is finished. From: Void Singer no matter how you do it, outside audio/visual media in SL tends to be a PITA. That's for sure. From: Void Singer you might be able to set a longer wait at each point of interest, or have it stop until the riders inform you they're ready to move on (via a button press or something) include a timeout so that one person that's busy doesn't hold up things too long I did ask the creators of the tour system if there was a way to pause the tour and they said there was not. I'm guessing there is some magic combination of parcel media flags (stop, pause, unload, loop set, something) that will make this work more reliably. Given that SL can display incredibly complex visuals to hundreds (OK, maybe tens) of people at the same time, you would thing they could deliver a 20 second mp3 to two avatars reliably. I understand that the audio streaming is out of their control somewhat (is dependent on the speed of the streaming server to deliver the audio), but I can query that server by other methods and it always responds with the file I want when I want it. Sigh, Doug
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-22-2009 07:43
From: DrDoug Pennell Hi Void,
I don't think is is correct. I'm pretty sure that as long as I use the PARCEL_MEDIA_COMMAND_AGENT, flag, that only the avatar who is sitting in the seat (or who has been detected by the sensor/collision) will hear the audio. That is how multiple people on the same parcel can watch different videos at the same time. On my other tour it only plays for those on the tour. If you are standing next to the tour vehicle on the same parcel (but out of sensor range) you do not hear the audio. oops, yeah you are absolutely right on that one, my memory is a little fuzzy on parcel media, because it's not something I use often.. sorry for the miscue.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|