• Help, Angle Problem
    3 replies, posted
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. [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. [/code]shared.lua [code] 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 )) [/code] [URL="http://www.facepunch.com/"]View Image[/URL] [IMG]http://img812.imageshack.us/img812/7512/gmflatgrass0007.jpg[/IMG] [URL]http://img812.imageshack.us/img812/7512/gmflatgrass0007.jpg[/URL] [URL="http://www.facepunch.com/"]View Image[/URL] [IMG]http://img714.imageshack.us/img714/2311/gmflatgrass0006j.jpg[/IMG] [URL]http://img714.imageshack.us/img714/2311/gmflatgrass0006j.jpg[/URL] [URL="http://www.facepunch.com/"]View Image[/URL] [IMG]http://img808.imageshack.us/img808/7180/gmflatgrass0008.jpg[/IMG] [URL]http://img808.imageshack.us/img808/7180/gmflatgrass0008.jpg[/URL]
Use Angle:RotateAroundAxis to rotate around the local axises of the vehicle [code] gunang = vang+Angle(0,0,0) gunang:RotateAroundAxis(gunang:Up(),ang.yaw) self.Gun:SetAngles(gunang) [/code] (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.
[QUOTE=ralle105;25357577]Use Angle:RotateAroundAxis to rotate around the local axises of the vehicle [code] gunang = vang+Angle(0,0,0) gunang:RotateAroundAxis(gunang:Up(),ang.yaw) self.Gun:SetAngles(gunang) [/code] (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.[/QUOTE] Thx. SUCCESSFULLY APPLIED. Really Thank! [media]http://img214.imageshack.us/img214/3290/gmecm0001.jpg[/media] [media]http://img836.imageshack.us/img836/7210/gmecm0004.jpg[/media]
Glad I could help:tiphat:
Sorry, you need to Log In to post a reply to this thread.