Hi there,
I haven’t used Timers before but I’m trying to set one up that carries an int as a payload/parameter in my UObject child class.
The goal is to be able to detect if an input has been held down for at a given amount of time (delay) or more.
The method using the timer (called every frame):
bool UMagic::testInputInitTime(int spellIndex, bool input)
{
float delay = 0.1;
FTimerDelegate del;
del.BindUObject(this, &UMagic::finishDelayTimer, spellIndex);
UWorld* const world = GEngine->GetWorldFromContextObject(this);
FTimerManager timerManager = world->GetTimerManager();
if (input)
{
// Input is held
if (!timerManager.IsTimerActive(del))
// If delay timer is not set, set it
timerManager.SetTimer(del, delay, false);
}
else
{
passedDelay[spellIndex] = false;
timerManager.ClearTimer(del);
}
return passedDelay[spellIndex];
}
And the method at the other end of the timer:
void UMagic::finishDelayTimer(int spellIndex)
{
passedDelay[spellIndex] = true;
}
The above code fails to compile with:
1>c:\program files\unreal engine\4.1\engine\source\runtime\engine\public\TimerManager.h(434): error C2248: 'FNoncopyable::FNoncopyable' : cannot access private member declared in class 'FNoncopyable'
1> C:\Program Files\Unreal Engine\4.1\Engine\Source\Runtime\Core\Public\Templates\UnrealTemplate.h(264) : see declaration of 'FNoncopyable::FNoncopyable'
1> C:\Program Files\Unreal Engine\4.1\Engine\Source\Runtime\Core\Public\Templates\UnrealTemplate.h(257) : see declaration of 'FNoncopyable'
1> This diagnostic occurred in the compiler generated function 'FTimerManager::FTimerManager(const FTimerManager &)
Could anybody point out what I’m doing wrong, or maybe suggest a better way of doing this?
Thanks