Velocity & DeltaTime
We are going to look into how we can set our platform at a vector velocity it’s member variables and movement framerate independent using deltatime.
We have been updating a single component at a time so far, but let’s update the whole vector at once. We are going back to our header. We want to create a moving platofrm velocity vector.
We are going to create a new FVector that sets our platform velocity.
Back over in the cpp file we are going to change our X location to currentLocation + velocity
Our platform now flies at 100 units in the X direction every frame.
We need to implement deltatime into our function.
- Using deltatime in Unreal can tell us how long each from took to execute.
- When we multiply by delta time is make our game “frame rate independent”
We are multiply our velocity by delta time.
Our cube is now moving at a normal speed that we would expect and our cube is frame rate independent.