You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? SELF DRIVING CAR, All i need is now to turn my angles into steer float
-
What is the issue? It never return between -1,1 though the target angle returns correctly
-
What solutions have you tried so far? Linear formula, broken, Another linear formula, still broken, the devforum says that -1 is -90 and 1 is 90 though No one give me the formula for that
local function steer(target)
local PositionDifference = (target.Position - script.Parent.PrimaryPart.Position).Unit
local GoalFrontVector = script.Parent.PrimaryPart.CFrame.LookVector
local DotProduct = PositionDifference:Dot(GoalFrontVector)
local Angle = DotProduct
local TargetAngle1 = math.deg(math.acos(Angle))
local TargetAngle = TargetAngle1 - 90
if TargetAngle < 90 then
TargetAngle = TargetAngle
end
if TargetAngle > 90 then
TargetAngle = 90 - TargetAngle
end
print(TargetAngle)
chassis.UpdateSteering(here should be my formula,script.Parent.PrimaryPart.AssemblyLinearVelocity.Magnitude)
chassis.UpdateThrottle(script.Parent.PrimaryPart.AssemblyLinearVelocity.Magnitude,0.21)
end
local function complicatedlerp(angle)
return angle*-1/-90
end