I am still very confused on how I would be able to achieve the car movement that Cities: Skylines uses. If you haven’t played Cities Skylines before then here is an example of what I’m trying to achieve. The Most Cars I've EVER seen in Cities Skylines! - YouTube 1:18 - 1:25. How would I be able to set up a road or highway and have the cars drive on it correctly.
I’ve tried pathfinding, raycasting, and even tried detecting other objects around the car but I still cannot figure out how to achieve my goal.
Yes, I’m trying to make a game similar to Cities: Skylines. Where you can place the road to a highway and eventually a car gets on it. I just do not know how I would manage to make a car do that.
I have an idea. Why don’t you make an invisible part for the car to follow, and tween the part along the road. That should solve the angle problems. I’m making right now an example.
Some roads will have lanes so I’m not sure if that will work. Pathfinding will just make the car move directly to the point without moving on the road. Using conveyors I’m not sure if I could do that either.
1.you take a car from toolbox or custom made
2. unanchor the car so it can move freely
3. get a conveyor from the toolbox or custom made
4. weld it to the car
5.add BodyAngularVelocity
6.set the volicity to a VERY high number Dont do infinity
7.Run the game to see if it works
local car = script.Parent
local goal = car.Parent.Goal
local IdealCframe = CFrame.new(car.Position, goal.Position)
local distanceGoal_Car = (car.Position-goal.Position).magnitude
local Idealposition = IdealCframe.LookVector.Unit * (distanceGoal_Car - 5) --your offset so it doesn't bug out
local BF = Instance.new("BodyPosition")
BF.Position = Idealposition
BF.Parent = car
local BG = Instance.new("BodyGyro")
BG.CFrame = IdealCframe
BG.MaxTorque = Vector3.new(40000,40000,40000)
BG.Parent = car
local update = function()
IdealCframe = CFrame.new(car.Position, goal.Position)
distanceGoal_Car = (car.Position-goal.Position).magnitude
Idealposition = car.Position + IdealCframe.LookVector.Unit * (distanceGoal_Car - 5)
BF.Position = Idealposition
BG.CFrame = IdealCframe
end
while true do
wait()
update()
end
now all you have to do is tween the Goal part along the roads and make a algorithm for every road bit, like curves and so on, to tween the goal part so it seems that the car is going on the road
Make a small invisible brick. Make another long invisible one and use that as the path it will follow. Simply have the invisible brick follow that path. Then, take your car and position it on the lane. Use TweenService to move the car to the invisible part following the path. Do this for every lane.