Hi,
I have been stuck on a problem for days trying to make a UObject tickable. I made it inherit from FTickableGameObject and have overridden its isTickable and isTickableInEditor functions in order to make them tickable only on play. Although isTickableInEditor always returns false, the uobject starts ticking in-editor as soon as compile is over. My original post remains unanswered as of this post.
It was then suggested to me that I should override isTickable to return the following:
// .cpp file, UMessageDispatcher is the name of my class. It inherits from both UObject and FTickableGameObject
bool UMessageDispatcher::IsTickable() const
{
if (GWorld)
{
return (!IsTemplate(RF_ClassDefaultObject)) && !(GIsEditor && !GWorld->HasBegunPlay());
}
return true;
}
This method is great because it makes sure that the CDO doesn’t tick, only the real instance. The problem, however, is that it always returns false. I therefore checked each boolean to locate the problem. Important note: I instantiate my class object inside the constructor of my GameInstance, which I assume begins play before any other actor in the scene. The results:
- IsTemplate(RF_ClassDefaultObject) returns false: This is expected because I call it from the UMessageDispatcher instance (my tickable uobject).
- GisEditor is true whether I am in play or not. Again, expected behaviour.
- HasBegunPlay() is where there is a problem. Whether I am in play or not, it will always return false, which is responsible for isTickable to always return false.
I further researched the problem and found out that HasBegunPlay() only returns true once everything else has already begun playing. This would explain why, since I initialized my object in myGameInstance, HasBegunPlay() is still false.
This is probably a design decision from the UE developer team, but it makes HasBegunPlay() a misleading term (if I understand correctly). As of now, I am unaware of any way to fix the issue, with the exception of maybe using global flags, but this is a special brand of malpractice that I would like to avoid. Is there a documented workaround or is this truly a bug? I post this anyway, in case I indeed am onto something.
My apologies if this is not the proper way to report a bug, it’s the first time I ever do it.