Neading help for detecting stearing angle

try using

local unit = (destination.Position - thisCar.Position).Unit
local angle = math.atan2(unit.x, unit.z) -- (might end up being unit.z, unit.x)
HingleConstraint.TargetAngle = angle
2 Likes

I got mixed results…
When is going towards X cordinate line, it works

But when it goes to Z…


ignores it…

i tried to flip math.atan2(unit.X, unit.Z), but nothing happend…
and i tried this angle=math.deg( math.atan2(unit.X, unit.Z) ) but i got…


it going around…

1 Like

I will give ya car model if you want to test it or just take it
test car model.rbxm (1.4 MB)

1 Like

ok, im gonna check your code!

(30 characters)

1 Like

It is hard…
It may take time

1 Like

No problem, its not something extra important or something like that, take your time and go easy

Your code (with math.deg) inherently is a good idea, but you’re calculating the angle from only positions, which realistically does not work, since if the car is rotated, the target angle has to adjust accordingly. This is why the car points into the right direction at the very beginning, but doesn’t update its wheels during motion. To “fix” your current solution, just adjust the angle according to the car orientation.

angle = math.deg(math.atan2(unit.X, unit.Z)) - thisCar.Orientation.Y+180
3 Likes

Cool!

I maked auto pilot using @emojipasta code!

test car model.rbxm (2.9 KB)

I was stupid to forget that… anyway thanks man :smiley:

did you send right model? i get from your model just route model?

Thank you all for your hard work, if i can somehow help you, tell me!

Woops, i send wrong file…

test car model.rbxl (101.9 KB)

This is correct one

1 Like

Wow this looks nice, few seconds later car dies i have to modify this, thank you anyway

You can delete

script.Parent:BreakJoints()

to protect car lol

I know but it looked funny…
Just wroom to last point and then brek

may i also ask what effect does #destination have on destination value?
(what # does?)

#destination:GetTouchingParts() returns a number.
This will return the number of parts the destination is touching.

i did small modifcation on script so it dont destroys parts on contact, destroys them on distance, i will use this with path finding service
code modification:
if (destination.Position-script.Parent.Center.Position).magnitude <= 1 then

Cool!
I had no such idea!

(30 characters bruhhhhh)

yes 30 chars is long i know, this car was supousted to be for builders to get on building place in robico (tropico 1 copy on roblox {yes there was no cars but hey}) but now it can be used even bether