The cylindricalconstraints in my turret system aren’t going to the desired angle setpoint. The code I’m using is shown below. The angles returned by atan2 seem reasonable and are within -180 and 180. It’s just that for some reason the servos don’t wanna move…
--Angle set function:
function LightTank:SetTurretLookVector(lookVector: Vector3)
local side = math.deg(math.atan2(lookVector.X, lookVector.Z))
local up = math.deg(math.atan2(lookVector.X, lookVector.Y))
local cannon = self.Model.CannonAssembly
local upHinge: CylindricalConstraint = cannon.GunMount.RollController
local turretRing: CylindricalConstraint = cannon.TurretMount.TurretRing
upHinge.TargetAngle = up
turretRing.TargetAngle = side
print("Tried to go to", side, up)
end
--Initialization
local cannon = new.Model.CannonAssembly
local upHinge: CylindricalConstraint = cannon.GunMount.RollController
local turretRing: CylindricalConstraint = cannon.TurretMount.TurretRing
upHinge.ServoMaxForce = math.huge
turretRing.ServoMaxForce = math.huge
upHinge.ServoMaxTorque = math.huge
turretRing.ServoMaxTorque = math.huge