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
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
I got mixed results…
When is going towards X cordinate line, it works
But when it goes to Z…
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…
ok, im gonna check your code!
(30 characters)
It is hard…
It may take time
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
I was stupid to forget that… anyway thanks man
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!
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