Re: [Mod Contest Entry: Auto-Defense System] GS Defenses
thesoupiest wrote:
If I knew -how- to make a one-directional turret, I would.
I recently found out that it is possible to override the actor's sharp aim by constantly setting AnalogAim (found in the Controller class), but I'm not 100% sure this works under AI control.
Code:
function Create(self)
self.Ctrl = self:GetController()
end
-- limit aim to the first quadrant (up-right)
function Update(self)
if self.Ctrl.AnalogAim.AbsRadAngle > 0.2 then
self.Ctrl.AnalogAim = Vector(1,0):RadRotate(0.2)
elseif self.Ctrl.AnalogAim.AbsRadAngle > 1.5 then
self.Ctrl.AnalogAim = Vector(1,0):RadRotate(1.5)
end
end
-- limit aim to the second quadrant (up-left)
function Update(self)
if self.Ctrl.AnalogAim.AbsRadAngle < 1.6 then
self.Ctrl.AnalogAim = Vector(1,0):RadRotate(1.6)
elseif self.Ctrl.AnalogAim.AbsRadAngle > 3 then
self.Ctrl.AnalogAim = Vector(1,0):RadRotate(3)
end
end
The if-statements will be a little bit more complicated if you want to be able to aim in both first and fourth quadrant.