Just a few hours ago, I was able to complete a fully functional vehicle chassis that I will be using for my game, however one feature that I’ve been having trouble figuring out is designing the autopilot system.
My first idea was to create a node system by placing parts all over my map, however one concern is part count, my map is quite a large scale so I’ve been thinking twice on how I’m gonna accomplish this. The chassis has a detector part that will touch the nodes and will tell the chassis where to go next, this will also help me calculate the fastest route to a pinned location on my map.
Another idea was to create pre-marked locations on the GPS, however this seems so limiting and the possibilities of the node system is just so overwhelming and expandable.
What are your thoughts on the methods I’ve came up with? and if you happen to come up with another method for my provided use case please share it with me
In what manner are you able to direct your vehicle to move? Is it a traditional car with a throttle/steering setup? If so, there is really 2 parts of the problem you need to solve.
The first part is generating the actual path to follow. This can be done through a multitude of methods; what I do personally and would suggest is that you map out a set of waypoints and then generate a Hermite Spline for your vehicle to follow.
The second part is then actually having your vehicle follow this path. Again, multiple methods exist for this. Methods may vary for specific dynamics of your system. For example, if you have a 4 wheel skid-steered platform, the dynamics of that are different than that of a traditional ackerman steered vehicle. Trajectory tracking for nonholonomic systems is still a pretty active area of research, so there still tons of approaches to this problem. They span from traditional and simple solutions, such as pure pursuit, to ones that implement non-linear state-space controllers.
For ROBLOX, I would really just suggest doing something simple that can be applied to tons of different vehicle types. A pure pursuit controller would be best suited for this, as you really don’t need to know your actual dynamics.
Another issue I’ve been figuring out is how will I get the backend of the system running. What I initially planned was to create a module script that the server can communicate with and control the target vehicle, however another concern is latency, will I sacrifice user experience over security? But that’s another topic I cannot go into detail.
It’s a constraint based chassis with the ackerman steering system with a slight twist.
I could come up with a plugin that can generate a table with Vector3 points, pretty simple, however I am sacrificing the Touched events if I decide to not go with the part nodes. I am also exploring other methods at the moment. I also haven’t heard of the Hermite Spline before, although I think this is similar to the T-Spline used in Autodesk Fusion 360, I might consider going for this, thanks for this information.
Will this apply to an active steering system? (The rear wheels will turn at a minute angle when going for sharp turns.)
I started porting the pure pursuit algorithm with a few modifications, while this is very close to what I would like to achieve, my team member suggested creating a custom algorithm with makes use of Pure Pursuit and *A so that we can implement our own speed and steering calculations.
Touched event for nodes is a bad idea anyway. I rarely rely on touched for things that are absolutely critical and must work on the first touch. However you move the vehicles using your own system, you should be checking distance from the tracking part to the node’s position, so Vector3 in a table is good. If you choose to use Tweening (which I’ve done before for a small scale AI traffic system) you can also start the tween to the next node as part of the callback.
If you have road pieces, you could also use raycasting to find the next roadpiece, although it’s likely more efficient to have your game determine all the node positions during initialisation and stores them, or indeed using a plugin to generate them in studio.