Manipulating the Z rot of C1 with the mouse's Vertical Pos Relative to the Camera, In a fixed cone?
Alright, So lets begin.
I need a way to make the barrel of my cannon move up and down with the script, the cannon is attached to a Boat, and it's Pivot's rotation is independent of the boat.
How would I go about doing this? I also would like to be able to incorperate firing cone of about 15? from the top. So rather than a 90? Firing cone it would only be 75?
What is the correct way to Collet the Mouses Y Axis location and parse it correctly to always be between 0-75? and facing the Front face towards the end of the barrel, I also need it to be able to return the angle? What would be the C-Framing magic needed for this?
Calc(int) was a method I devised as an attempt before.
03 | mouse = game.Players.LocalPlayer:GetMouse() |
04 | Rotor = Workspace.Model.Rotor |
05 | ScreenY = game.Workspace.CurrentCamera.ViewportSize.Y |
08 | Gun = Workspace.Model.Gun |
12 | local Res = math.rad((ScreenY*Y/ 90 )) |
17 | elseif Res <minAngle then |
28 | RotorPos = Rotor.Position |
30 | dir = (mouse.Hit.p - RotorPos).unit |
33 | Rotor.RotorWeld.C 1 = CFrame.new( 0 , 1.5 , 0 ) * CFrame.Angles( 0 , (math.atan 2 (dir.X, -dir.Z) + math.pi), 0 ):inverse() |
40 | Gun.GunWeld.C 1 = CFrame.new( 0 , 0 , 0 )*CFrame.Angles( 0 , 0 , 0 ) |