From 750831645dd0d8e463e3b81a29a090258032c154 Mon Sep 17 00:00:00 2001 From: Logan Gartner Date: Fri, 25 Mar 2022 23:45:12 -0600 Subject: [PATCH] Optimized spectator hologram --- modules/client/cl_spectate.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/client/cl_spectate.txt b/modules/client/cl_spectate.txt index 520c0b8..52e05e8 100644 --- a/modules/client/cl_spectate.txt +++ b/modules/client/cl_spectate.txt @@ -91,11 +91,15 @@ if player() == owner() then do else --Freecam local position = eyePos() + local lastSentPosition = eyePos() - timer.create("updateholo", 1, 0, function() - net.start("LSFT-LoadHolo-Update") - net.writeVector(position) - net.send() + 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