And it says to use inherits specifier to inherit from FTickableGameObject. But as I was browsing trough ObjectBase.h, there is no such thing for UCLASS().
So tried to do it in normal way
class UObjectDerived : public UObject, public FTickableGameObject
Can you provide some additional details as to what didn’t work. That syntax should work in general and there is at least one example (UEnvQueryManager) that has the same declaration syntax. Do you have the necessary include paths setup?
UCLASS(Blueprintable, BlueprintType)
class URPGEffectBase : public UObject, public FTickableGameObject
{
GENERATED_UCLASS_BODY()
void Tick(float DeltaTime) OVERRIDE;
bool IsTickable();
TStatId GetStatId();
Error:
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(24): error C2220: warning treated as error - no 'object' file generated
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(24): warning C4263: 'bool URPGEffectBase::IsTickable(void)' : member function does not override any base class virtual member function
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(153): warning C4264: 'bool FTickableObjectBase::IsTickable(void) const' : no override available for virtual member function from base 'FTickableObjectBase'; function is hidden
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(33) : see declaration of 'FTickableObjectBase::IsTickable'
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(14) : see declaration of 'FTickableObjectBase'
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(25): warning C4263: 'TStatId URPGEffectBase::GetStatId(void)' : member function does not override any base class virtual member function
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(153): warning C4264: 'TStatId FTickableObjectBase::GetStatId(void) const' : no override available for virtual member function from base 'FTickableObjectBase'; function is hidden
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(36) : see declaration of 'FTickableObjectBase::GetStatId'
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(14) : see declaration of 'FTickableObjectBase'
1>D:\Unreal\Rocket\Engine\Source\Runtime\CoreUObject\Public\UObject\Class.h(1894): error C2259: 'URPGEffectBase' : cannot instantiate abstract class
1> due to following members:
1> 'bool FTickableObjectBase::IsTickable(void) const' : is abstract
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(33) : see declaration of 'FTickableObjectBase::IsTickable'
1> 'TStatId FTickableObjectBase::GetStatId(void) const' : is abstract
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(36) : see declaration of 'FTickableObjectBase::GetStatId'
1> D:\Unreal\Rocket\Engine\Source\Runtime\CoreUObject\Public\UObject\Class.h(1932) : see reference to function template instantiation 'void InternalConstructor(const FPostConstructInitializeProperties &)' being compiled
1> with
1> [
1> TClass=URPGEffectBase
1> ]
1> D:\Unreal\RPG\Intermediate\BuildData\Include\RPG\RPG.generated.inl(92) : see reference to function template instantiation 'void GetPrivateStaticClassBody(const TCHAR *,const TCHAR *,UClass *&,void (__cdecl *)(void))' being compiled
So I thought. I’m missing OVERRIDE macro for the rest of functions. And I added one and here is another error:
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(24): error C3668: 'URPGEffectBase::IsTickable' : method with override specifier 'override' did not override any base class methods
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(24): warning C4263: 'bool URPGEffectBase::IsTickable(void)' : member function does not override any base class virtual member function
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(153): warning C4264: 'bool FTickableObjectBase::IsTickable(void) const' : no override available for virtual member function from base 'FTickableObjectBase'; function is hidden
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(33) : see declaration of 'FTickableObjectBase::IsTickable'
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(14) : see declaration of 'FTickableObjectBase'
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(25): error C3668: 'URPGEffectBase::GetStatId' : method with override specifier 'override' did not override any base class methods
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(25): warning C4263: 'TStatId URPGEffectBase::GetStatId(void)' : member function does not override any base class virtual member function
1>d:\unreal\rpg\intermediate\builddata\include\rpg\../../../../Source/RPG/RPGEffectBase.h(153): warning C4264: 'TStatId FTickableObjectBase::GetStatId(void) const' : no override available for virtual member function from base 'FTickableObjectBase'; function is hidden
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(36) : see declaration of 'FTickableObjectBase::GetStatId'
1> d:\unreal\rocket\engine\source\runtime\engine\public\Tickable.h(14) : see declaration of 'FTickableObjectBase'
Indicating that there is nothing to override. I though maybe I’m missing header file “#include “Tickable.h””, added it and nothing changed.
And as side question. How would I go about implementing
bool IsTickable()
For now I just set it to return true, but I’m sure it is not good idea.
For IsTickable and GetStatId the functions are const, so that will probably be most part of your declaration problem. I do strongly recommend marking them virtual for clarity though the C++ standard will let you get away without it.
Depending on your purpose IsTickable simply returning true may be appropriate as many of our uses do. If there is some state that needs to be true when you want the tick you could put that logic in there as well.
In case anyone wanders in here i found some reference about it here, to avoid the classic "404 Page not found when someone sees this in the future, i’ve copied the code on this answer. But i take no credit for it.
Which it pretty much the same everyone above said, but with an added check for the default constructed object like this:
UCoolDownMgr::UCoolDownMgr()
{
bIsCreateOnRunning = GIsRunning; ///Here's the difference
}
void UCoolDownMgr::Tick(float DeltaTime)
{
//Don't invoke Super::Tick(), otherwise would link failed!!!
//Super::Tick(DeltaTime);
}
bool UCoolDownMgr::IsTickable() const
{
//notify engine to ingore Tick of the object constructed before game running.
return bIsCreateOnRunning;
}
TStatId UCoolDownMgr::GetStatId() const
{
return UObject::GetStatID();
}
It also explains how to do it another way with a tick delegate.