Results 1 to 4 of 4

Thread: timer event

  1. #1

    Default timer event

    Hey. I'm having trouble getting a Timer() event to function correctly inside of a state. I've previously used timers in my code without hassle but for some reason i cannot get this one to activate.

    This is an example of my code:

    Code:
    class MyClass extends Pawn;
    var int count;
    
    state Building
    {
        function beginState()
        { 
           count = 0;
           log("DEBUG TEST 1");
           SetTimer(0.5, true);
           log("DEBUG TEST 2");
        }
    
        event timer()
        {
           log("DEBUG TEST 3");
           count ++;
           log("count is: "@count); 
           if (count == 5)
              endState();
        }
    
        function endState()
        {
        }
    }
    Assuming that the state is successfully activated using GotoState('Building'); in a sub class and the log displays:

    DEBUG TEST 1
    DEBUG TEST 2

    But nothing is ever logged from inside the Timer() and no warnings or errors are given. I thought there might be a boolean declared in the parent class that is preventing the use of timers (eg. bRequiresTick prevents Tick() events) but i haven't been able to find one.

    If anyone can find any logic errors in this code or have ideas for a solution it would really help.

  2. #2
    MSgt. Shooter Person
    Join Date
    Jul 2006
    Location
    Inna Jungle
    Posts
    255

    Default

    Hey, that is odd. Looks fine to me.

    This reminds me of some problems using functions (ScriptedActions) that run right at the top of match start. To work around those similarly odd problems, I usually add a timer step before, just to wait a second before running that action. Could you test putting the SetTimer() after beginstate?

  3. #3

    Default

    Hey, thanks for the reply. My problem was just a logical error in another piece of code i didn't provide. I was changing states before the timer completed its first loop. But thanks for the assistance anyway

  4. #4
    MSgt. Shooter Person
    Join Date
    Jul 2006
    Location
    Inna Jungle
    Posts
    255

    Default

    Glad to hear you tracked it down.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.