You have to use something of the following to access time manager instance:
GetWorldTimerManager()
or
GetWorld()->GetTimerManager()
You have to use something of the following to access time manager instance:
GetWorldTimerManager()
or
GetWorld()->GetTimerManager()
I need help in making a timer work.
if (bIsFiring == 0)
{
bIsFiring = 1;
GetWorldTimeManager()::SetTimer(this, &AThridPCharacter::ShowOnScreen, 1.0f, true);
}
And
void AThridPCharacter::ShowOnScreen()
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Start fire"));
}
This shows errors
1>D:\ue4\New folder\ThridP\Source\ThridP\ThridPCharacter.cpp(83): error C2143: syntax error : missing ‘;’ before ‘SetTimer’
1>D:\ue4\New folder\ThridP\Source\ThridP\ThridPCharacter.cpp(83): error C3861: ‘GetWorldTimeManager’: identifier not found
1>D:\ue4\New folder\ThridP\Source\ThridP\ThridPCharacter.cpp(83): error C2664: ‘UINT_PTR SetTimer(HWND,UINT_PTR,UINT,TIMERPROC)’ : cannot convert argument 1 from 'AThridPCharacter *const ’ to ‘HWND’
Do I need to use a delegate as a parameter in the timer function? I have never used delegates till now.
Sorry I mistyped it. I used GetWorldTimeManager().
Does a timer require a delegate as a parameter? I used a function as a parameter.
It’s actually GetWorldTimerManager(), typo on my side.
And it is used like this:
GetTimerManager().SetTimer
not
GetTimerManager()::SetTimer
Ok it worked thanks. Why is it written as :: in the documentation?
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Timers/index.html
Some other reasons or just plain error?
What is the reason “.” is used here instead of “::”? Sorry if i am asking too many questions I just want to know this language better.
Copy-paste error i guess, copied reference from above and just replaced FTimeManager with getter function
I’ve fixed the offending documentation, thanks for poingint this out.
In C++ :: is only used for calling static functions, that is to say functions that are not called on a specific instance of the class, but are, in essence, global functions.
GetWorldTimerManager() returns a reference to an instance of a timer manager, and so we use the . to indicate that we wish to call a function on it.
If GetWorldTimerManager() were to return a pointer we would use →
Ain’t C++ grand?
Thank you… I understood now.