Skip to content

Commit ad58c59

Browse files
committed
lock part aim smoothing
allows for smoothing / less aggressive control of the eye angles by doing an iterated lerp to target every frame
1 parent 8c8759e commit ad58c59

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lua/pac3/core/client/parts/lock.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ BUILDER:StartStorableVars()
6666
:GetSet("AffectPitch", true)
6767
:GetSet("AffectYaw", true)
6868
:GetSet("ContinuousAim", true)
69+
:GetSet("SmoothAiming", false, {description = "Gradually ease into the target angle by only changing the angle by a fraction every frame instead of fully setting it immediately"})
70+
:GetSet("SmoothFraction", 0.05, {editor_clamp = {0,1}})
6971

7072
:SetPropertyGroup("TeleportSafety")
7173
:GetSet("ClampDistance", false, {description = "Prevents the teleport from going too far (By Radius amount). For example, if you use hitpos bone on a pac model, it can act as a safety in case the raycast falls out of bounds."})
@@ -99,11 +101,16 @@ local function set_eyeang(ply, self)
99101
ang.r = 0
100102
if not self.AffectPitch then ang.p = plyang.p end
101103
if not self.AffectYaw then ang.y = plyang.y end
102-
ply:SetEyeAngles(ang)
103104
elseif self.Mode == "AimToPos" then
104-
local ang = (pos - ply:EyePos()):Angle()
105+
ang = (pos - ply:EyePos()):Angle()
105106
if not self.AffectPitch then ang.p = plyang.p end
106107
if not self.AffectYaw then ang.y = plyang.y end
108+
end
109+
if self.SmoothAiming then
110+
local lerped_ang = LerpAngle(self.SmoothFraction, plyang, ang)
111+
lerped_ang.r = 0
112+
ply:SetEyeAngles(lerped_ang)
113+
else
107114
ply:SetEyeAngles(ang)
108115
end
109116
end

0 commit comments

Comments
 (0)