Apparently the LookVector line in the combined code caused it to be slammed. I had to use the old way, and it was going too fast which caused it to fly. The problem is now, I want it to immediately look at the next waypoint after it went after the previous waypoint. It has a weird delay, then it looks at the waypoint. I don’t want that.
And it also appears to get stuck at waypoints. It went on a infinite loop between two straight waypoints! Is there a way to change the radius of the waypoints it finds?
And now when I increase the velocity, it gets stuck in the middle of 3 straight waypoints! This is really fusterating and this is becoming into a hot mess.
How would I use the BodyPosition?
if you read the articles, you will see that you have to set the bodyposition’s Position property to the wayPoint’s position.
try this
local waypoint = findClosestWaypoint()
bodyPosition.Position = waypoint.Position
bodyGyro.CFrame = CFrame.new(script.Parent.Parent.Position, waypoint.Position)
doing this will aim it towards the closest waypoint once
if you want it to loop through them, do this:
for i in pairs(workspace.WayPoints:GetChildren()) do
local waypoint = workspace.WayPoints['WayPoint'..i]
bodyPosition.Position = waypoint.Position
bodyGyro.CFrame = CFrame.new(script.Parent.Parent.Position, waypoint.Position)
repeat wait(0.1) until (script.Parent.Parent.Position - waypoint.Position).Magnitude < 3 -- checks until it gets within 3 studs of the waypoint -you may have to adjust the 3 to something else depending on how close you want it
end
Cool, cool! I got the slamming thing through. I used the second code. But for some reaosn it only goes through one waypoint.
the second one will loop through all of the children in workspace.WayPoints. For this to work make sure the name of the waypoints is exactly WayPoint1, WayPoint2, WayPoint3, etc.
I edited the code to match my waypoint names. They are named correctly but the car is only going through one - what’s the problem?
make sure to adjust the number 3 i was talking about (you will want to make it higher), read what is commented right next to it.
Also its weird that its working at all, you mispelled the name Waypoints, it should be WayPoints
You can change it to that be remember to change the script as well
Adjusted to 10, but for some reason it went to the waypoint adjacent to the one it went to. How do I make it ONLY to find waypoints from the front face?
it will go to the waypoints from smallest number to largest: it will first go to waypoint1, then waypoint2, etc. Also it sounds like you have to keep adjusting the magnitude
Oops, heheh. it was human fault. I just named them by list
But then when it gets to a certain waypoint, it fails and falls off the course. How can I make it so it automatically changes the Magnitude based on how far it is?
what do you mean fails and falls off the course?
I made the waypoints for the road but for some reason when it gets to a corner it falls off.
Also btw what if I want it to go to a intersection, and it goes to another path? How would I set this up? And the waypoint numbering thing is getting a bit tiring.
if you dont want to use physics, you can make it extremely reliable via tweenservice. It will be anchored and never fall off, but the downside is that there will be no physics interaction. The numbering method is the best way to do an intersection scenario, as it is being given a direct command on where to go next.
you will find this useful:
I wouldn’t want the car to be anchored. I want it to follow waypoints with suspension.