Getting relative speed using delta time

To make our speed value relate to direction, we first need to multiply it by delta time. Delta time is based on the fact that the time taken between the frames of the gameplay can differ. By multiplying our speed value by delta seconds, we can ensure that the speed at which our object moves is the same, regardless of the game's frame rate.

To do this, drag the Speed variable onto Event Graph and choose GET to create the Speed node. Now, right-click on empty graph space and search for delta. Select the Get World Delta Seconds option to place the corresponding node on the Event Graph. Finally, drag the output pin from either the Get World Delta Seconds node or the Speed node, and drop it into an empty space. Type an asterisk in the search field (Shift + 8 on most computers) and select the Float * Float node.

Finally, drag and drop the other output pin onto the remaining input pin of the new multiplication node to multiply these two values, like this:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset