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)
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)
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.
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.
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.
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.
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)
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)