Download

Delta time setting velocity on character

Hey so I’m trying to make my character move by setting the x velocity in my AIs BTTaskNode class in execute task but I realised that it is different speeds with different frame rates, so I tried getting and implementing delta time, which I did, but my character still moves at different speeds with different frame rates. Please can someone help me out, thank you! :smiley:

I guess I would need my BTTaskNode to call at the same rate as Tick but I have no idea how to do that…

UWorld::GetDeltaSeconds

1 Like

Thats what I did, and it didn’t work, the character still moves at different speeds with different frame rates

Shouldn’t the behaviour tree just give the AI the target location? And the movement component would “drive” the AI to the given location.

So instead of setting with velocity, should I set with target location instead? Can you give me the code for that, thank you :slight_smile:

Velocity should work correctly regardless of framerate. It’s only if you’re manually moving the character should you normally worry about delta time. But if you use a behavior tree it should let you make the character path find to the right location as well, provided you build the navmesh correctly.

1 Like

I thought that too but my character clearly moves slower at different fps
So I measured the time from the start of the game where my character instantly starts moving to the right to the point it hits the wall and prints that time and I did this in two different fps
~120fps - TimeToGetToEdge = 0.85 seconds
30fps - TimeToGetToEdge = 2.6 seconds