Optimized spectator hologram

This commit is contained in:
Logan G 2022-03-25 23:45:12 -06:00
parent b700d3c109
commit 750831645d
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -91,11 +91,15 @@ if player() == owner() then do
else
--Freecam
local position = eyePos()
local lastSentPosition = eyePos()
timer.create("updateholo", 1, 0, function()
timer.create("updateholo", 0.25, 0, function()
if position:getDistance(lastSentPosition) > 10 then
net.start("LSFT-LoadHolo-Update")
net.writeVector(position)
net.send()
lastSentPosition = position
end
end)
hook.add("calcview", "freecam", function(posin, angin, fovin, znearin, zfarin)
@ -140,9 +144,8 @@ if player() == owner() then do
local up = bool_to_number(input.isKeyDown(KEY_UP)) - bool_to_number(input.isKeyDown(KEY_DOWN))
local thing = Vector(forward, left, 0)
thing:rotate(Angle(elevation, bearing, 0))
position = position + thing * SPEED * (input.isKeyDown(KEY_RUN) and MULTIPLER or 1) * (timer.frametime()/(1/(200/3)))
position = position + thing:getRotated(Angle(elevation, bearing, 0)) * SPEED * (input.isKeyDown(KEY_RUN) and MULTIPLER or 1) * (timer.frametime()/(1/(200/3)))
position = position + up * Vector(0,0,SPEED) * (input.isKeyDown(KEY_RUN) and MULTIPLER or 1) * (timer.frametime()/(1/(200/3)))
end)
end