Im making a tank game and i really like the scope of GHPC (Gunner Heat PC). If you dont know how the scope works here is a video that explains it, i did manage to get it to work but its just way to hard to controll once zoomed in.
The current code:
Server (the vehicle script)
local testX = 0
local testY = 0
game.ReplicatedStorage.PlrMouse.OnServerEvent:Connect(function(plr,Tank,OGPos,NewPos)
if Tank == script.Parent then
testX = math.clamp((OGPos.X)/100-(NewPos.X)/100,-5,5)
testY = math.clamp((OGPos.Y)/100-(NewPos.Y)/100,-3,3)
end
end)
... other code
if turretSeat then
if testX ~= 0 then
Steer += testX--turretSeat.Steer/Precision --TODO This needs to be the same as in in the -math.rad()
Turret.PrimaryPart.Motor6D.C1 = Turret.PrimaryPart.Motor6D.C1 * CFrame.Angles(0, math.rad(testX), 0)
end
if testY ~= 0 and ((abs(Throttle + testY)) <(GunAngleRange + 1)) then
Throttle += testY--turretSeat.Throttle/Precision --TODO This needs to be the same as in the -math.rad()
Gun.Motor6D.C1 = Gun.Motor6D.C1 * CFrame.Angles(0, 0, -math.rad(testY))
end
end
Client
local pos
local ButtonDown = false
Mouse.Button2Down:Connect(function()
pos = Vector2.new(Mouse.X,Mouse.Y)
ButtonDown = true
end)
Mouse.Button2Up:Connect(function()
ButtonDown = false
game.ReplicatedStorage.PlrMouse:FireServer(Tank.Value,pos,pos)
end)
Mouse.Move:Connect(function()
if ButtonDown == true then
game.ReplicatedStorage.PlrMouse:FireServer(Tank.Value,pos,Vector2.new(Mouse.X,Mouse.Y))
else
game.ReplicatedStorage.PlrMouse:FireServer(Tank.Value,pos,pos)
end
end)
Any idea on how to make it better and more like the GHPC version?