Constant Tick Rate

I’m developing a game where you can manipulate time. At the moment I have created a TimeObject class where the static mesh’s location, rotation and velocity are stored every tick.

I thought this was a good solution until I played the game on my other computer and realised that the tick rate was completely different, due to performance I assume. This has made all my counters for the amount of data that can be stored to be different depending on your machine.

How can I set up a constant tick rate in Unreal Engine so that I have complete control on how much time is recorded and can be rewound by?

Thanks again.

DeltaTime is your friend

Could you elaborate on how DeltaTime can help? I’ve had a quick experiement with it, by replacing the Tick(DeltaSeconds) with Tick(DeltaTime) and the value for DeltaTime is different on my two computers. On my desktop it’s 0.017… and laptop it’s 0.034.

I’m just worried that this will cause problems further down the line, when it comes to rewinding particles/ai/animations/etc

Cheers

MyObject.h



class UMyObject : public UObject
{
private:
   float Elapsed;

protected:
   void Tick(float DeltaSeconds) override;

public:
   float Delay;
}


MyObject.cpp



void UMyObject::Tick(float DeltaSeconds)
{
   Super::Tick(DeltaTime);

   Elapsed += DeltaTime;
   if(Elapsed < Delay) return;

   Elapsed -= Delay;

   // do your synced stuff
}


DeltaSeconds/DeltaTime whatever it may be
you need to include it in your calculations, eg

rather than
something += somevalue;
use
something += somevalue*deltatime;

Okay, I think I understand, I’m going to have a reformat tonight, and should have some successful results. Thanks a lot guys, great help as usual!