# Need help implementing Delta Time for physics simulation

**URL:** <https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [February 2, 2024, 12:26pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215 "2024-02-02T12:26:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AzaelOff](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/azaeloff/32/1108429_2.png) [@AzaelOff](https://forums.unrealengine.com/u/AzaelOff)\
**Post date:** [February 2, 2024, 12:26pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215/1 "2024-02-02T12:26:02Z")

</div>

Hello everyone,

So I have been working on a roller coaster simulation project for a few days and managed to get trains to travel along a spline with gravity and friction… Unfortunately I used a Marketplace asset as a template and I am now stuck with a problem I cannot solve.

Basically my trains use the location and rotation at a certain distance along the spline to set the location of each car. The physics is calculated on the front and back wheels, then both calculations are added and divided and that gives me my speed (see screenshot and BP)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/d/30d67fc8c77d342ce904d77717ad5bb92cbea143.jpeg)

> **[Calculate Speed posted by anonymous | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/4zy7ody3/)**
>
> No description provided

The velocity is then multiplied by the Delta Seconds of the Event Tick and the result is used as an increment to find the next distance on the spline (see screenshot and BP)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/e/f1e27eda2ba13e6a1740eb0f28538bcdc5f41d84.png)

> **[Set location along Spline posted by anonymous | blueprintUE | PasteBin For...](https://blueprintue.com/blueprint/4ot-6bq6/)**
>
> No description provided

My issue is that the velocity math seems to still depend on the frame rate even if the delta seconds is “implemented” as from what I observed, the velocity decreases massively (as far as I can see when printing) when the frame rate is low, but the train moves “faster” (as in it can run longer, like if friction affected it differently).

I tried multiple things, I first used a constant instead of the Delta Seconds (I used 0.016, which is the delta of 60fps) to define the Speed variable, it makes the velocity math constant but the trains updates slower, and I’m stuck ever since…

I will attach a video of the current code posted above, running the simulation at 60 and 15 fps.

Hope this is enough information to hopefully help anyone that can help me.

Thanks.

Video: [https://youtu.be/YGz3Pd20hKs](https://youtu.be/YGz3Pd20hKs)

(the purple and blue values are front and back Velocity, the red is Speed (Velocity\*DeltaSeconds))

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 2, 2024, 12:39pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215/2 "2024-02-02T12:39:35Z")

</div>

Not enough time to study the script - apologies. But do consider looking into _Async Physics Tick_ - not only does it run on a separate thread, but also does so at a fixed interval.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/7/de77deaa1a20781a9ce6816bf1a75b7c5239dcc9.png)

Move my simulations over and never looked back, it seems to be working great. Admittedly, it’s a somewhat new feature so tread with care.

edit - this:

[https://portal.productboard.com/epicgames/1-unreal-engine-public-roadmap/c/381-asynchronous-physics-simulation](https://portal.productboard.com/epicgames/1-unreal-engine-public-roadmap/c/381-asynchronous-physics-simulation)

---

<div class="post-metadata">

**Author:** ![AzaelOff](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/azaeloff/32/1108429_2.png) [@AzaelOff](https://forums.unrealengine.com/u/AzaelOff)\
**Post date:** [February 2, 2024, 12:53pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215/3 "2024-02-02T12:53:01Z")

</div>

Would it work in a default blueprint ? My actor doesn’t “simulate physics” like the engine defines it, it’s only math, I will try the node though and see.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 2, 2024, 12:59pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215/4 "2024-02-02T12:59:38Z")

</div>

> [@AzaelOff](#):
>
> Marketplace asset as a template […] it’s only math […] to get trains to travel along a spline with gravity and friction

Out of sheer curiosity - what method / system does the plugin (?) use, Is it similar to this:

> [@Make a Ground Rail with Spline](https://forums.unrealengine.com/t/make-a-ground-rail-with-spline/789343/2):
>
> On the most fundamental level: check the inclination of the spline with dot product accumulate this value - that’s the speed use speed to progress through a spline You’ll need to add friction as this preserves energy as perfectly as frame time allows it. And input. And a gazillion other things that makes it a game. innocent

This fakes physics, for example.

---

<div class="post-metadata">

**Author:** ![AzaelOff](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/azaeloff/32/1108429_2.png) [@AzaelOff](https://forums.unrealengine.com/u/AzaelOff)\
**Post date:** [February 2, 2024, 1:10pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215/5 "2024-02-02T13:10:54Z")

</div>

> [@Everynone](#):
>
> Out of sheer curiosity - what method / system does the plugin (?) use, Is it similar to this:

It uses the exact same code, but it updates the meshes an overly complicated way… The physics are also frame dependent on that asset (complete project)

> [@Everynone](#):
>
> This fakes physics, for example.

Yes this is technically what my code does, using gravity, friction and the rotation of both the front and back car to simulate near-accurate coaster physics…

I have tried the Async node you suggested and it seems like it’s a good beginning, it makes the math stay frame independent, but the train meshes update slower (I’m using the delta seconds from the event node)

---

<div class="post-metadata">

**Author:** ![AzaelOff](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/azaeloff/32/1108429_2.png) [@AzaelOff](https://forums.unrealengine.com/u/AzaelOff)\
**Post date:** [February 3, 2024, 3:59pm UTC](https://forums.unrealengine.com/t/need-help-implementing-delta-time-for-physics-simulation/1660215/6 "2024-02-03T15:59:23Z")

</div>

After further testing I think I cannot use the Async Physics Tick as it produces very noticeable stutter and blur (blur probably due to TSR)…

I feel like I’m just misunderstanding what I should multiply by delta seconds…
