@@ -11,20 +11,21 @@ function Create(self)
11
11
end
12
12
function Update (self )
13
13
local parent = self :GetParent ();
14
- if parent and IsActor (parent ) then
15
-
16
- local parent = ToActor (parent );
17
- local controller = parent :GetController ();
18
-
19
- if controller :IsState (Controller .MOVE_RIGHT ) then
20
- self .rotation = self .rotation + self .turnSpeed ;
21
- end
22
- if controller :IsState (Controller .MOVE_LEFT ) then
23
- self .rotation = self .rotation - self .turnSpeed ;
24
- end
25
- -- Spread / tighten aim when moving up / down
26
- if controller :IsState (Controller .MOVE_DOWN ) then
27
- self .verticalFactor = self .verticalFactor - self .turnSpeed ;
14
+ if parent then
15
+ if IsActor (parent ) then
16
+ parent = ToActor (parent );
17
+ local controller = parent :GetController ();
18
+
19
+ if controller :IsState (Controller .MOVE_RIGHT ) then
20
+ self .rotation = self .rotation + self .turnSpeed ;
21
+ end
22
+ if controller :IsState (Controller .MOVE_LEFT ) then
23
+ self .rotation = self .rotation - self .turnSpeed ;
24
+ end
25
+ -- Spread / tighten aim when moving up / down
26
+ if controller :IsState (Controller .MOVE_DOWN ) then
27
+ self .verticalFactor = self .verticalFactor - self .turnSpeed ;
28
+ end
28
29
end
29
30
if math.abs (self .rotation ) > 0.001 then
30
31
self .rotation = self .rotation / (1 + self .turnSpeed * 2 );
@@ -36,9 +37,9 @@ function Update(self)
36
37
else
37
38
self .verticalFactor = 0 ;
38
39
end
39
- -- Aim directly away from parent ship
40
+ -- Aim directly away from parent
40
41
local posTrace = SceneMan :ShortestDistance (parent .Pos , self .Pos , SceneMan .SceneWrapsX ):SetMagnitude (self .searchRange / 2 );
41
- self .RotAngle = (1.57 * self .verticalFactor + posTrace .AbsRadAngle ) / (1 + self .verticalFactor ) - self .rotation ;
42
+ self .RotAngle = (1.57 * self .verticalFactor + posTrace .AbsRadAngle + ( parent . HFlipped and math.pi or 0 ) ) / (1 + self .verticalFactor ) - self .rotation ;
42
43
if self .areaMode then -- Area Mode
43
44
local aimPos = self .Pos + Vector ((self .searchRange / 2 ), 0 ):RadRotate (self .RotAngle );
44
45
-- Debug: visualize aim area
0 commit comments