How would I move a non-humanoid object with pathfinding using WASD-like controls?

I’m currently working on a pathfinding system for a non-humanoid object, a car.
The issue is that pathfinding gives Vector3 values for all path waypoints, but I have no way to follow those coordinates as my car uses forwards, backwards, left and right controls instead of following a Vector3 point like Humanoid:MoveTo(x,y,z)

How would I make my car know when to turn, accelerate or brake to achieve the goal?

1 Like

Hi there, you don’t need a humanoid to add pathfinding in the car. However, if you want the car to move by it self, theres a option in the VehicleSeat.Steer (The direction of movement, tied to the keys A and D. Must be one of 1 (right), 0 (straight), or -1 (left). Will refresh back to 0 unless constantly set.)

VehicleSeat.Throttle (The direction of movement, tied to the keys W and S. Must be an integer 1 (forward) 0 (null) or -1 (reverse). Will refresh back to 0 unless constantly set.)

leftsteer = VehicleSeat.Steer = -1
rightsteer = VehicleSeat.Steer = 1
middlesteer = VehicleSeat.Steer = 0

If you want to add pathfinding to it make sure you use a accurate stopping counter on the script,
Use DotProduct or cross-product to make something like this (if a waypoint is that direction the car steers to that direction, if the waypoint is in the middle then stop steering, also just to notice, Slowdown the car steering speed a little bit , this will make it that car steer perfectly.

1 Like

Hi,

Thanks for your help, I really appreciate it since I’m kind of ignorant on this Pathfinding thing.
However, I’m having some trouble using the solution you provided.

I’m currently using LookVector:Dot() but this since this value never returns negative the driving script doesn’t know whether to turn left or right.