Hello, I am currently trying to recreate the AI trucks like in the game Clustertruck. I couldn’t really find anything on how to do such a thing while searching the internet, so I would really appreciate some help.
(Disclaimer: I am not at all asking for a script directly, I simply need help with where to start.)
The trucks move based on manually placed nodes, they don’t actually use pathfinding. I found this out because I tried using the editor in the game.
There are 3 types of nodes, which are red, green, and blue. Each truck can be assigned 1 node color to follow.
Basically, all you need to do is to make the truck drive towards the next node, then once it reaches that node, you can start driving towards the next node.
You can check if you need to steer left or right by using the angle between the truck’s head and the next node to follow.
Great thank you! I am also wondering how I would get the truck itself to steer/move to the node itself. I am really bad with vehicles (sorry).
Edit: I’ve been messing around with a simple car and automating the throttle (yes I know my phrasing is bad). I couldn’t get the node to detect the car that was touching it when I was driving the car manually. I still have not figured out how to automate the car.
For detecting if the truck has reached the next node, you could try a distance check instead of a .Touched event or :GetPartsInParts, and it would probably look like this:
local distance = (truck:GetPivot().Position - node.Position).Magnitude
if distance < 6.5 then
-- start targetting next node
end
If I’m gonna be honest, it took me a few weeks to learn how constraints work and how to make a simple car. I’ll try making a basic constraints truck model for you tomorrow.
Whoops, I completely forgot that I was supposed make a car lol. Anyways, I just finished making it now, so here it is: ClusterTruck Truck Model.rbxm (13.2 KB) (make sure to ungroup (CTRL+U) it in workspace)