in a plugin, i want use to call SetTimer() to make my function tick, how to get the world ptr to use it? is there any way to do it?
thank you !
i write a plugin, there is a Singleton class, i want make a tick function for it. it not a AActor, it is a UObject.
is there some way to do this ?
If you are using () with an object that derives no higher from UObject then you need to override ().
The best override would be:
{
return GetOuter()->();
}
Also, when spawning that UObject you need to specify the outer, from the spawning function, which is
NewObject<>(“Outer here which must be at least an AActor”)
#include “Tickable.h”
UCLASS()
class MY_API UMyClass : public UObject, public FTickableGameObject
{
GENERATED_BODY()
public: // you must override these
virtual void Tick(float DeltaSeconds) override {}
virtual bool IsTickable() const override { return true; }
virtual TStatId GetStatId() const override { return TStatId(); }
}
thank you !
by the way, is there any way to setting DeltaSeconds ? i dont want tick to much, for example, 1 tick per second?
Tick triggers on every frame that engine generates not in fixed time, Delta time is there so any changes you do is time based not frame based like this, it’s estimated time that will pass between the frames
X = X + (Y * DeltaSeconds);
Now Y becomes number added to X per second, not number added per frame which would happen if you would not scale Y to DeltaSeconds.
If you want function trigger in fixed amount of time use timer on the loop, considering you been searchin for SetTimer() i guess you know how to use them already
yes, i know
thank you very much !