Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Manipulating the Z rot of C1 with the mouse's Vertical Pos Relative to the Camera, In a fixed cone?

Asked by
vat21s 0
10 years ago

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.

01--==LOCAL SCRIPT==--
02--Variables
03mouse=game.Players.LocalPlayer:GetMouse()
04Rotor=Workspace.Model.Rotor
05ScreenY=game.Workspace.CurrentCamera.ViewportSize.Y
06minAngle=0
07maxAngle=75
08Gun=Workspace.Model.Gun
09 
10function Calc(Y)
11 
12    local Res=math.rad((ScreenY*Y/90))--Ratio'd using  Result/2Pi=90y/90 -- 90y= 90*y == ScreenY*Y
13    --If Resulting angle >75
14    if Res>maxAngle then
15        return maxAngle
View all 41 lines...

Answer this question