I am following the AI Vehicle tutorial by Jourverse to make a truck with a trailer follow a spline. I am using the City Sample Vehicle and have encountered an issue when reversing the truck with the trailer.
Problem:
When the truck reverses, the trailer doesn’t follow the spline properly. The trailer bends incorrectly and doesn’t stay on the path it should.
Attempts to solve the issue:
I’ve tried modifying the Constraint Trailer to make it more rigid when reversing, but this causes the trailer not to turn correctly and doesn’t fix the problem.
Possible solution:
I was thinking that a possible solution could be to make the trailer rotate from the rear wheels when the truck reverses, so it follows the spline properly. However, I’m not sure how to implement this.
Request for help:
I would greatly appreciate any help or solutions you can offer.
This happens because the vehicle AI component only controls the vehicle body, while the trailer’s movement is governed by physics. A more complex system is required to understand the situation and make adjustments accordingly. When reversing, the vehicle head of the semi-truck pushes the trailer. You need to track the trailer’s direction so the vehicle can make turning angle calculation to push it to the desired location. https://youtu.be/-wVobD4Juhc?si=qxcXWl4T2tkxovWf
Thank you very much for your response.
I have been thinking about that possibility, and honestly, I am not able to come up with a working solution.
I don’t know if you know of any tutorial that covers this topic, as I have been searching for a long time and haven’t found anything similar.
In fact, I’ve seen that the tutorial I followed to create the base of the vehicle is yours.
I wanted to thank you for the videos because the system is really good, and I’ve learned a lot thanks to it.
Best regards.
I’m running some tests and making some progress, but it’s not very useful so far.
I have created a socket on the rear wheels of the trailer. I have also created the Calculate Steering Input function on the trailer and I calculate it from the socket.
When the truck reverses, I get the trailer’s steering input because that way I can see the position of the rear wheels relative to the path.
The problem I see is that I don’t know how to straighten the trailer before it turns too much in relation to the truck, making it impossible to maneuver.