Car Simulation Different every time I play it

Hi guys. I am working on a car configurator and I want the car to come driving into the scene. Currently I am manually tweaking the throttle and Brake so that it arrives at my desired destination. The issue is, that it stops at different positions almost every time I run it. The simulation seems to be affected by system resources (if I do other stuff, e.g. move the camera or whatever, it slows down the process, and the sim seems to skip a few steps, ending in the car stopping sooner).

Any idea how to solve this? Is there a way to point the car to what exact position it should stop, so that I dont need to guess the throttle and brake values?

I’m currently using this setup. The sequence first makes the car follow the path, Use Throttle, and after a delay, it uses the brakes. I’d appreciate any insight into a better solution to this, as it’s very finicky and unpredictable!

Hi Grimgorkos,

The problem here is how often that ā€˜Event Tick’ ticks (since every tick = 1 frame and frame rate can fluctuate)

Try multiplying ā€˜Delta Seconds’ from event tick with your floats. (This may require different input numbers though)

For a completely different approach, maybe try recording yourself driving onto the playform with take recorder.

EDIT: A few days ago this tutorial about using vehicles + splines + take recorder came out. Just wanted to drop a link to it here for posterity!

Cheers

1 Like

check when car is at end of path and then apply brakes.

Thanks, that sounds like a really straightforward solution, how would I implement it? Any specific nodes I should know about?

Didnt know ā€œTake Recorderā€ as an option" thanks, I’ll try that out as a workaround!

1 Like

I would like to try @darusoftware 's approach first as I’d have more control over the animation in the long-run and can fine-tune the settings. So you know how to get the car to stop when it reaches the end of the curve? What nodes would I need for that?

There is that ā€˜Finished’ pin that fires from your timeline when you reach the end of the curve, but I don’t think that will solve the problem of the curve values getting processed differently based on FPS.

That question did spark another idea - what if you have a collision box, and when the car enters it, the collision box sends a message to the car telling it to brake.

Maybe this way any differences in throttle wont matter and possibly the braking will happen so fast that even small variances due to frametime fluctuations wont matter.

BTW you can type ā€˜t.maxfps 30’ into the console to lock a lower framerate for testing.

1 Like

That sounds like a great solution!

I’m currently trying it out, but I’m not sure what I’m doing wrong. That car drives along the curve, but it doesnt stop when it enters the collision box. From my understanding this is a basic ā€œIf-Thenā€ operation. If car is in box → use brakes. What is wrong in my blueprint? Do you see anything obvious?

Just to clarify, I added the Collision Box into the same blueprint of the car. Is that correct?

Just to add to what others have said, the physics are non deterministic, even given a constant time step it might not always look the same, especially on different systems. Also, if you happen to adjust the car physics (power or something else) the car drives differently and you would have to readjust your animation. The most reliable way would be to simply disable physics and push the car along with an animation, also animating the wheels. Making a simple AI to brake at a set point will probably also work fine.

Right now your collision box is attached to your car, meaning it will push it along and never reach it. You would either have to make it’s location absolute in the properties panel, detach it on BeginPlay or move it to a separate blueprint.

Okay, so I went and did the whole ā€œtake recordingā€ route, and it works within the recorded sequence, but the animation itself is static with only the wheels having been animated. How do I get the entire object transformation included here?
At the moment I am using the ā€œPlay animtionā€ node to play the recorded animation at ā€œEvent BeginPlayā€.

I managed to solve the issue by using a ā€œTrace Lineā€ node.

I am adding an object to the right side of the platform where it should stop on. The Lien trace detects the static mesh and then uses the ā€œif trueā€ state to trigger the brakes.

1 Like