I made a parallel thread over at OldUnreal forums, if the answer arrives there first, I will post the solution here.
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, 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
Is there any 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...)
Thanks for any help!
Music for area - trigger on/off when player entering/leaving
-
- Novice
- Posts: 18
- Joined: Thu Nov 03, 2016 1:04 pm
-
- Masterful
- Posts: 717
- Joined: Mon Jan 05, 2009 8:08 pm
- Personal rank: Banished member
Re: Music for area - trigger on/off when player entering/leaving
This is very easily done! Lots of my maps have this same idea, and not only with sound but with lights as well.... I'll prepare a map for you
This member can only post when permitted.
-
- Novice
- Posts: 18
- Joined: Thu Nov 03, 2016 1:04 pm
Re: Music for area - trigger on/off when player entering/leaving
That is great to hear, thanks a lot Terraniux!! Looking forward to a working example, once I have the template it will be so useful! (including for lights you say? even more useful!)
-
- Masterful
- Posts: 717
- Joined: Mon Jan 05, 2009 8:08 pm
- Personal rank: Banished member
Re: Music for area - trigger on/off when player entering/leaving
Try this! ( See attachment)
A little explaination:
1 Before starting, type "killpawns" in console to get rid of the bots.
2 Some triggers have intervals of 5 seconds ( toggle) and some of 1 minute to hear at least the music for a moment.
3 Left 1 room for you open to toy with as practice =)
You can edit however you like
Hope this helps... yell if something is unclear
Regards Terraniux
A little explaination:
1 Before starting, type "killpawns" in console to get rid of the bots.
2 Some triggers have intervals of 5 seconds ( toggle) and some of 1 minute to hear at least the music for a moment.
3 Left 1 room for you open to toy with as practice =)
You can edit however you like
Hope this helps... yell if something is unclear
Regards Terraniux
You do not have the required permissions to view the files attached to this post.
This member can only post when permitted.
-
- Novice
- Posts: 18
- Joined: Thu Nov 03, 2016 1:04 pm
Re: Music for area - trigger on/off when player entering/leaving
Brilliant stuff this is! Thanks a lot for your help Terraniux!!Terraniux wrote: ↑Fri Aug 07, 2020 6:08 pm Try this! ( See attachment)
A little explaination:
1 Before starting, type "killpawns" in console to get rid of the bots.
2 Some triggers have intervals of 5 seconds ( toggle) and some of 1 minute to hear at least the music for a moment.
3 Left 1 room for you open to toy with as practice =)
You can edit however you like
Hope this helps... yell if something is unclear
Regards Terraniux
I played around to see how things work, I love that you integrated different triggers for the purpose of demonstration, that's awesome!
I see why I had problems too: turns out you can simply rely on Blank.umx to shut down the music whereas I was trying with the MusicEvent's bSilence property (never got it to work).
The best thing about your test map is it shows how you can easily add interactivity too (with the lights also): it's not just about an area music setup, but playing with switches etc. Gives me new ideas (beyond the bar I mentioned)
Thanks again for your help and I hope others will easily find this thread to benefit from your test map too!
P.S.: I like your custom .umx tracks!
Cheers
-
- Masterful
- Posts: 717
- Joined: Mon Jan 05, 2009 8:08 pm
- Personal rank: Banished member
Re: Music for area - trigger on/off when player entering/leaving
I've build entire disco's based on this concept! Great stuff! Haha
Glad I could help.
Regards Terraniux
Glad I could help.
Regards Terraniux
This member can only post when permitted.
-
- Novice
- Posts: 18
- Joined: Thu Nov 03, 2016 1:04 pm
Re: Music for area - trigger on/off when player entering/leaving
Yeah I dig the disco concept too and thanks to gopostal I got a Disco Ball in the game too!
To wrap things up here, I would like to share another solution I got over at OldUnreal:
Yrex got back to me with an elegant solution - a custom actor called literally AreaMusic, it's not online tested but for anyone making SP maps it's great - basically the actor allows you to define the music that will play in a zone (defined by a ZoneInfo actor) and so you enter the zone the music plays, you exit and the music can change/stop depending on what you told the AreaMusic to do in another zone.
It's not for interactivity, but for literally defining an ambient track for an area that doesn't require dynamic change of tracks it is probably the simplest solution.
Link to thread:
https://www.oldunreal.com/cgi-bin/yabb2 ... 1596751038
Direct link to yrex's test map with his custom AreaMusic actor:
Love this community!
EDIT: topic title can be marked as "[SOLVED]"
To wrap things up here, I would like to share another solution I got over at OldUnreal:
Yrex got back to me with an elegant solution - a custom actor called literally AreaMusic, it's not online tested but for anyone making SP maps it's great - basically the actor allows you to define the music that will play in a zone (defined by a ZoneInfo actor) and so you enter the zone the music plays, you exit and the music can change/stop depending on what you told the AreaMusic to do in another zone.
It's not for interactivity, but for literally defining an ambient track for an area that doesn't require dynamic change of tracks it is probably the simplest solution.
Link to thread:
https://www.oldunreal.com/cgi-bin/yabb2 ... 1596751038
Direct link to yrex's test map with his custom AreaMusic actor:
Love this community!
EDIT: topic title can be marked as "[SOLVED]"
-
- Godlike
- Posts: 2194
- Joined: Sun Oct 05, 2008 3:31 am
Re: Music for area - trigger on/off when player entering/leaving
I think you type
killall bot
or
killall bots
I get confused from addbot 8 or addbots 8
killall bot
or
killall bots
I get confused from addbot 8 or addbots 8
Binary Space Partitioning
-
- Godlike
- Posts: 2912
- Joined: Fri Sep 25, 2015 9:01 pm
- Location: moved without proper hashing
Re: Music for area - trigger on/off when player entering/leaving
For the ones interested in this:
Source code of Actor 'AreaMusic'
Code: Select all
//=============================================================================
// AreaMusic. Not tested online.
//=============================================================================
class AreaMusic expands Info;
struct ZoneMusic
{
var() ZoneInfo Zone;
var() Music Song;
var() byte SongSection;
var() byte CdTrack;
var() EMusicTransition Transition;
};
var() ZoneMusic ZoneSongs[32];
var PlayerPawn player;
var ZoneInfo oldPlayerZone;
function PostBeginPlay()
{
SetTimer(1,false);
}
function Timer()
{
local Pawn P;
for(P=Level.PawnList;P!=none;P=P.NextPawn)
{
if(PlayerPawn(P) != none && Spectator(P)==none)
{
player = PlayerPawn(P);
break;
}
}
}
function Tick(float deltaTime)
{
local byte i;
if(player != none)
{
if(player.Region.Zone != oldPlayerZone)
{
for(i=0;i<32;i++)
{
if(ZoneSongs[i].Zone == player.Region.Zone)
{
player.ClientSetMusic( ZoneSongs[i].Song, ZoneSongs[i].SongSection,
ZoneSongs[i].CdTrack, ZoneSongs[i].Transition );
break;
}
}
oldPlayerZone = player.Region.Zone;
}
}
}
Because Tick() is called multiple times per second and music change is not needed within milliseconds, I would have preferred Timer() for checking the Zone. Timer() is cheaper than Tick().
And because music selection is done by polling what is the worst proceed, I would have used the Zone Events ActorEntered() and ActorLeaving(). Event driven procedures are cheaper than polling.
</smart aleck mode>
"If Origin not in center it be not in center." --Buggie
-
- Godlike
- Posts: 6435
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: Music for area - trigger on/off when player entering/leaving
Entirely agree, that's why a zone has entry code and exit code, not only for physics checks.
-
- Novice
- Posts: 18
- Joined: Thu Nov 03, 2016 1:04 pm
Re: Music for area - trigger on/off when player entering/leaving
A bit above my head I'm afraid!sektor2111 wrote: ↑Sun Aug 09, 2020 8:11 amEntirely agree, that's why a zone has entry code and exit code, not only for physics checks.
Certainly for SP the AreaMusic actor code shared above is fine, I can imagine you are thinking about online play. If one of you can make an "online tested" optimised version, feel free to do so.
Thanks for raising awareness to the Zone Events ActorEntered() and ActorLeaving(), I didn't know about them beyond, implicitly, the physics checks between zones.
-
- Godlike
- Posts: 2912
- Joined: Fri Sep 25, 2015 9:01 pm
- Location: moved without proper hashing
Re: Music for area - trigger on/off when player entering/leaving
The problem of that code is that it is designed for a single player only (and works fine then). Let's switch to multi player: should all players get the same music? If so and Player A is in Zone 1 with music alpha and Player B in Zone 2 with music beta, what music should be played for both?
So this makes sense only, if different players can get different music. In this case above code has to be changed.
So this makes sense only, if different players can get different music. In this case above code has to be changed.
These events can only used by code. But there is a possibility to raise an Event, when a player enters a zone: it is at ZoneInfo>ZonePlayerEvent.
"If Origin not in center it be not in center." --Buggie
-
- Novice
- Posts: 18
- Joined: Thu Nov 03, 2016 1:04 pm
Re: Music for area - trigger on/off when player entering/leaving
You're making a lot of sense, thanks for elaborating! Maybe someone will be willing to pick this up and make the changes required for multiplayer?Barbie wrote: ↑Sun Aug 09, 2020 7:43 pm The problem of that code is that it is designed for a single player only (and works fine then). Let's switch to multi player: should all players get the same music? If so and Player A is in Zone 1 with music alpha and Player B in Zone 2 with music beta, what music should be played for both?
So this makes sense only, if different players can get different music. In this case above code has to be changed.
These events can only used by code. But there is a possibility to raise an Event, when a player enters a zone: it is at ZoneInfo>ZonePlayerEvent.
Then we can all just use that (also for coop on otherwise SP maps).