1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

[UT'99] How to interact with an actor, when level ends

Discussion in 'Programming' started by Raven, Sep 17, 2005.

  1. Raven

    Raven Member

    Joined:
    Jan 17, 2004
    Messages:
    147
    Likes Received:
    0
    I build mp3 player, and the problem is, that when I play mp3 in one level, and load another, mp3 keep playing :/. I tried 'event Destroyed' and mutator:
    Code:
    class RMp3PlayerStopper extends Mutator;
    
    var RMp3Player JukeBox;
    
    function AddMutator(Mutator M)
    {
        if ( M.IsA('RMp3PlayerStopper') )
        {
            return; //only allow one mutator
        }
        Super.AddMutator(M);
    }
    
    
    function BeginPlay()
    {
        foreach AllActors(class'RMp3Player', JukeBox)
           break;
        log("Mp3Player: mutator begins play");
    }
    
    function bool HandleEndGame()
    {      
          ShutDownMusicSys();
          Super.HandleEndGame();
          return False;
    }
    
    function ShutDownMusicSys()
    {
       log("Mp3Player: shuttin gdown");
       JukeBox.ShutDown();
       JukeBox.Destroy();
    }
    
    but nothing works. So my question is: how to interact with an actor, when level is about to change?
     
    Last edited: Sep 17, 2005
  2. Raven

    Raven Member

    Joined:
    Jan 17, 2004
    Messages:
    147
    Likes Received:
    0
    I've tried something else. I decide to spawn mp3player in entry level

    Code:
    (..)
    simulated function PostBeginPlay()
    {
    	if (Level.NetMode != NM_DedicatedServer)
    		SetTimer(1.0,true);
    }
    
    simulated function Timer()
    {
    
    	if (Level.NetMode == NM_DedicatedServer) return;
    
    	if (Level.LevelAction == LEVACT_None) {
    		foreach AllActors(class'PlayerPawn',PP)
    			break;
    
    		if (PP == none) return;
    
    		foreach PP.GetEntryLevel().AllActors(class'RMp3Player',JukeBox)
    			break;
    
    		if (JukeBox == none)
    			JukeBox = PP.GetEntryLevel().Spawn(class'RMp3Player');
    			
    		JukeBox.ReadPlayerPawn(PP);
    			
                    Mp3PlayerInit();
    		SetTimer(0, false);
    	}
    }
    (..)
    
    and check if new level is loading, and then stop playing sound

    Code:
    class RMp3Player extends Actor
          native
          config(user)
          NoUserCreate;
    
    var native string Directory;
    var config int MusicVolume;
    var bool bWasInitialized;
    var PlayerPawn PP;
    var LevelInfo CurLevel, OldLevel;
    //var bool bDoFade;
    //var bool bIsPaused;
    
    native(2230) final function bool MusicSystemInit();             //Initialize music system
    native(2331) final function bool PlaySong(string title);        //Plays song (use only for the first time)
    native(2432) final function StopSong();                         //Stop playing new song
    native(2533) final function ChangeVolume(int Volume);           //Changes volume
    native(2634) final function PlayNewSong(string title);          //Plays new song
    native(2735) final function ShutDown();                         //Shuts down music system
    //native(2836) final function PauseMusic(bool PauseMusic);        //Pause music
    
    function ReadPlayerPawn(PlayerPawn PlP)
    {
            PP=PlP;
            OldLevel = PlP.level;
    }
    
    
    event Tick(float Delta)
    {
    	if (PP == none || !bWasInitialized) return;
    
    	CurLevel = PP.player.console.viewport.actor.level;
    
    	if (CurLevel != OldLevel && CurLevel != Level)
    //        if(PP.player.console.viewport.actor.level.LevelAction == LEVACT_Loading)
            {
                    log("Mp3Player: InShuttingDown");
                    if(bWasInitialized)
                    {
    		     ShutDown();
    		     bWasInitialized=false;
    		}
    //		Destroy();
    	}
    }
    
    defaultproperties
    {
       Directory="../music/"
       MusicVolume=128
       bHidden=True
    }
    but then UT just hangs up with 'loading' screen. Nothig important appears in the log (just normal ut logs) :/
     
    Last edited: Sep 17, 2005
  3. Raven

    Raven Member

    Joined:
    Jan 17, 2004
    Messages:
    147
    Likes Received:
    0

Share This Page