Page 1 of 1

Music for area - trigger on/off when player entering/leaving

Posted: Thu Aug 06, 2020 9:57 pm
by Sat42
Hi all,

Been a while! Finally doing some more mapping ...

Title says it all: I have a corridor (of sorts) of convenient length leading to a bar; I want music (proper .umx, not sound) to kick in when the player enters the area, and the same track to fade away when the player exits the area. If the player backtracks for another visit, same music must kick in again and when leaving the area the music once more must fade away.

Of course the "fade in" trigger must be a bit further in than the "fade out" trigger (with what I've been playing with anyway).

That is the setup I am having trouble with, probably because I didn't have much time yet to look around so I am asking: how do you achieve the above, in such a way that the "fade in" and "fade out" music triggers can be triggered as much as one wants? (so there's always music in the bar, and never outside)

I would love a reply soon as I intend to share a little surprise map with my Dad next week for his birthday :P

Thanks for any help!

Re: Music for area - trigger on/off when player entering/leaving

Posted: Fri Aug 07, 2020 6:00 am
by medor
look here it's long to open http://medor.no-ip.org/index.php?dir=UEditor_Developing%2F&search=trigg&search_mode=f

you can to try this map test http://medor.no-ip.org/index.php?dir=UEditor_Developing/&file=Sektor_sound.zip

Re: Music for area - trigger on/off when player entering/leaving

Posted: Fri Aug 07, 2020 8:23 am
by Sat42
Thank you for pointing to your invaluable stash medor!
I had to connect via VPN to access it though as I kept getting "Time outs" here in Europe, slow indeed!

The test map is interesting for the new "Visible" sound actor (it gives you ideas) but it doesn't help solve my specific problem. I did have a look at some special triggers in your repository (ToggleTrigger.uc might help) but again it requires experimentation, and time is of the essence!

Can anyone point to a ready-made, vanilla solution for triggering the same music track on/off when entering/leaving an area? It has to be (indefinitely) repeatable.

(Meanwhile I am trying to finish the actual map...)

Re: Music for area - trigger on/off when player entering/leaving

Posted: Fri Aug 07, 2020 5:23 pm
by yrex .


Not tested online.

Re: Music for area - trigger on/off when player entering/leaving

Posted: Sat Aug 08, 2020 11:40 am
by Sat42


Not tested online.

Yrex - many thanks for your custom solution! It's simple and elegant - and I will be using this AreaMusic actor a lot! :D

It's so useful it deserves more recognition - may I share your solution over at UT99.org? Crediting you of course.

Thank you once more!  :)

Re: Music for area - trigger on/off when player entering/leaving

Posted: Sat Aug 08, 2020 2:50 pm
by yrex .
You can do anything you want, as long as you credit me.

Re: Music for area - trigger on/off when player entering/leaving

Posted: Sat Aug 08, 2020 3:39 pm
by Sat42
You can do anything you want, as long as you credit me.
Excellent, will share your test map with the custom AreaMusic actor over at UT99.org then!

Thanks again! :)



Re: Music for area - trigger on/off when player entering/leaving

Posted: Sun Aug 09, 2020 6:02 pm
by Buster
A great idea well executed. Good job. It will come in handy.

Re: Music for area - trigger on/off when player entering/leaving

Posted: Tue Sep 15, 2020 5:38 am
by .:..:
I checked that AreaMusic code and it's indeed singleplayer only.

I wrote this MusicEvent code a while ago which doesn't allow music to restart (you can trigger this event when entering one area, then switch to another song with another trigger when leaving it).

Code: Select all

Class FSMusicEvent extends MusicEvent;

var(MusicEvent) bool bForceRestartSong;

function Trigger( actor Other, pawn EventInstigator )
{
      local Pawn P;

      if ( bAffectAllPlayers )
      {
            // Fix for online games:
            Level.Song = Song;
            Level.SongSection = SongSection;

            for( P=Level.PawnList; P!=None; P=P.nextPawn )
                  if( PlayerPawn(P)!=None )
                        SetClientSong(PlayerPawn(P));
      }
      else
      {
            // Only affect the one player.
            if ( PlayerPawn(EventInstigator)==None )
                  return;

            // Go to music.
            SetClientSong(PlayerPawn(EventInstigator));
      }

      // Turn off if once-only.
      if ( bOnceOnly )
      {
            SetCollision(false,false,false);
            Disable( 'Trigger' );
      }
}
final function SetClientSong( PlayerPawn PP )
{
      if( PP!=None && PP.Player!=None && (bForceRestartSong || PP.Song!=Song || PP.SongSection!=SongSection) )
      {
            PP.ClientSetMusic( Song, SongSection, CdTrack, Transition );
            PP.Song = Song;
            PP.SongSection = SongSection;
      }
}

defaultproperties
{
      RemoteRole=ROLE_None
      bCollideActors=false
      bStatic=true
}