Announcement

Collapse
No announcement yet.

Can't make Dynamic Timers work?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can't make Dynamic Timers work?

    Hi guys.
    I have some weird problem going on here. I'm using TimerManager with a DynamicDelegate.
    And it just won't start or anything.

    Here's what I'm doing, plus log result.

    Code:
    void MyClass::BeginPlay()
    {
    	StateSystemDelegate.BindDynamic(this, &MyClass::TickStateSystem);
    	GetWorldTimerManager().SetTimer(StateSystemDelegate, 2.f, true); 
    }
    
    void MyClass::Tick(float DeltaSeconds)
    {
    	if (GetWorldTimerManager().IsTimerActive(StateSystemDelegate)) {
    		LOGYELLOW("########## StateSystemDelegateis active");
    	} else {
    		LOGYELLOW("########## StateSystemDelegateis not active");
    	}
    	float Remaining = GetWorldTimerManager().GetTimerRemaining(StateSystemDelegate);
    	LOGYELLOW("########## StateSystemTimer Remaining Time: %f",Remaining);
    }
    result - In every frame, log says:

    StateSystemDelegateis not active
    Remaining Time: -1.000000

    if I do the same with normal binds instead of dynamic ones, everything works.
    Any idea what's wrong?

    #2
    Is MyClass::TickStateSystem() tagged as a UFUNCTION()?
    Senior Engine Programmer, UE4, Epic Games
    Twitter:
    @Byooler

    Comment


      #3
      Originally posted by Jeff Farris View Post
      Is MyClass::TickStateSystem() tagged as a UFUNCTION()?
      hmm yes. Full Declaration was
      Code:
      UFUNCTION()
      void TickStateSystem();

      Comment


        #4
        Is your StateSystemDelegate being modified somehow between setting the timer and querying it? Maybe try setting a breakpoint in BeginPlay and either stepping into the BindDynamic call or stepping over it and examining StateSystemDelegate to see if it got bound properly. Also try stepping into the SetTimer call to see if it's failing somewhere. Alternatively, try adding your IsTimerActive call immediately after the SetTimer to see if it was set properly. If it was, something must be clearing your timer later.
        Senior Engine Programmer, UE4, Epic Games
        Twitter:
        @Byooler

        Comment


          #5
          Originally posted by Jeff Farris View Post
          Is your StateSystemDelegate being modified somehow between setting the timer and querying it? Maybe try setting a breakpoint in BeginPlay and either stepping into the BindDynamic call or stepping over it and examining StateSystemDelegate to see if it got bound properly. Also try stepping into the SetTimer call to see if it's failing somewhere. Alternatively, try adding your IsTimerActive call immediately after the SetTimer to see if it was set properly. If it was, something must be clearing your timer later.
          Ok thanks. I'll try this some time.

          Comment

          Working...
          X