Making a auto-rotating automatic gun but it doesn’t align with the target (though the steering engine uses virtually the same code and works???)
I tried changing the order of arguments within the CFrame configuration, the Torque, the density of implicated objects, but all failed.
No errors are to be found within the output, and the torque changed correctly as well.
Does anyone know the answer?
for i,v in pairs(script.Parent:GetChildren()) do
if v:FindFirstChild("Gun") then
print("Changing gyro (lol we're not)")
v.Gun.Base.BodyGyro.CFrame=CFrame.new(v.Gun.Base.BodyGyro.Parent.Position,player.Position)
v.Gun.Base.BodyGyro.MaxTorque=Vector3.new(0,1000,0)
end
end
i know that, i used it for other things and it worked
but for some reason not here
is it maybe due to the fact i already used a bodygyro for the car under it?
it’s attached using a hingeconstraint
(though then again, it wouldn’t explain why it moved using a BodyAngularVelocity)
you would be surprised how many times I’ve done this.
Classical Debug time!
for i,v in pairs(script.Parent:GetChildren()) do
if v:FindFirstChild("Gun") then
local from = v.Gun.Base.Position
local too = player.Position
local dir = (too-from)
print("From",from, "Too",too,"Dist",dir.Magnitude)
local p = Instance.new("Part",workspace)
p.Anchored = true
p.CanCollide = false
p.Size = Vector3.new(0.5,0.5, dir.Magnitude)
p.CFrame = CFrame.new(from,too)
p.Transparency = 0.75
p.BrickColor = BrickColor.Red()
game.Debris:AddItem(p, 1)
v.Gun.Base.BodyGyro.CFrame = CFrame.new( from, too )
end
end