Help, Angle Problem

I have one problem. anyone can solve it?
I’m working on APC. but Vehicle Angle is f-ed.
how to solve it?

here is code.



self.Veh = Vehicle
self.Gun = moving only left and right.
self.Gun2 = moving only up and down.
self.Gun3 = Ignore.
self.Seat1 = Ignore.
self.Seat2 = Ignore.


shared.lua




    pilot = self.Veh:GetDriver( )
    
    if not ValidEntity( pilot ) then
        self.TimeWithout = self.TimeWithout + delta
        return
    end
    
    self.TimeWithout = 0

    ang = pilot:GetAimVector( ):Angle( )
    vang = self.Veh:GetAngles()
gunang = Angle( vang.pitch, ang.yaw  , vang.roll ) + Angle ( 0 , 0 ,0)
    self.Gun:SetAngles( gunang )


pilot:ChatPrint("= Angle Info =")
pilot:ChatPrint("Aim Angle :")
pilot:ChatPrint(tostring(ang))
pilot:ChatPrint("Vehicle Angle :")
pilot:ChatPrint(tostring(vang))
pilot:ChatPrint("Gun Angle : ")
pilot:ChatPrint(tostring(gunang))


local angp = ang.pitch

if angp < 320 and angp > 30 then
angp = 320
end

    self.Gun2:SetAngles( self.Gun:GetAngles() + Angle( angp,0,-vang.roll ))    



			[View Image](http://www.facepunch.com/)

http://img812.imageshack.us/img812/7512/gmflatgrass0007.jpg

http://img812.imageshack.us/img812/7512/gmflatgrass0007.jpg

			[View Image](http://www.facepunch.com/)

http://img714.imageshack.us/img714/2311/gmflatgrass0006j.jpg

http://img714.imageshack.us/img714/2311/gmflatgrass0006j.jpg

			[View Image](http://www.facepunch.com/)

http://img808.imageshack.us/img808/7180/gmflatgrass0008.jpg

http://img808.imageshack.us/img808/7180/gmflatgrass0008.jpg

Use Angle:RotateAroundAxis to rotate around the local axises of the vehicle



gunang = vang+Angle(0,0,0)
gunang:RotateAroundAxis(gunang:Up(),ang.yaw)
self.Gun:SetAngles(gunang)


(For reference :Forward() is roll :Right() is pitch and :Up() is yaw)

Note: :RotateAroundAxis doesn’t return the rotated axis, it only modifies the angle object it’s being called on.

Thx. SUCCESSFULLY APPLIED.
Really Thank!

http://img214.imageshack.us/img214/3290/gmecm0001.jpg[/media]
[media]http://img836.imageshack.us/img836/7210/gmecm0004.jpg

Glad I could help:tiphat: