Hello all,
I am trying to have a timer delegate set-up with a method that has one parameter and a return type: ACharacter* AEnemySpawner::SpawnEnemy(const bool IsVisible).
This is set-up as follows: const FTimerDelegate EnemySpawnDelegate = FTimerDelegate::CreateUObject(this, &AEnemySpawner::SpawnEnemy, true); GetWorldTimerManager().SetTimer(SpawnTimerHandle, EnemySpawnDelegate, SpawnDelay, false);.
However, an error occurs on the line where the FTimerDelegate is declared:
error C2665: 'TDelegate<void (void),FDefaultDelegateUserPolicy>::CreateUObject': none of the 2 overloads could convert all the argument types
note: could be 'TDelegate<void (void),FDefaultDelegateUserPolicy> TDelegate<void (void),FDefaultDelegateUserPolicy>::CreateUObject<AEnemySpawner,bool>(const UserClass *,void (__cdecl AEnemySpawner::* )(bool) const,bool)'
DelegateSignatureImpl.inl(299): [C2665] or 'TDelegate<void (void),FDefaultDelegateUserPolicy> TDelegate<void (void),FDefaultDelegateUserPolicy>::CreateUObject<AEnemySpawner,bool>(UserClass *,void (__cdecl AEnemySpawner::* )(bool),bool)'
There is also another error brought up by the IDE I’m using (Rider):
To clarify, I would like the Character pointer returned, to be used in a method of another class. The timer is currently used in the AEnemySpawner class to handle spawning of enemies, soon after play begins.
Please let me know where I have gone wrong here, if a return type is allowed in a timer delegate, and if not, what the preferred solution would be, to refer to a pointer initialised in the method of another class.
Please also let me know if you require any further details, to help me resolve this problem.
