Hello FP
What I'm trying to do is when the players position and angles are the same as the postion and angles I want them to be, it should then remove the hook but the thing is, it doesnt remove the hook when they're met, you can see by the gif below how i move the entity around and although the angles/position isn't met the hook is still removed.
[url]https://gyazo.com/f5871341344f6c9a75ab02a04bdb9ee4[/url]
As you can see, the hook shouldn't be removed unless the positions and angles are the same as desPos and desAng.
[LUA]
net.Receive("OnUseInterface", function()
local entity = net.ReadEntity()
local curPos, curAng = LocalPlayer():GetPos() + Vector(0,0,100), LocalPlayer():GetAngles()
hook.Add("CalcView", "CalcInterfaceView", function(player, origin, angles, fov)
if not IsValid( entity ) then return end
local destPos = entity:LocalToWorld(Vector(0,70,55))
local destAng = entity:LocalToWorldAngles( Angle(0,-90 ,0) )
-- destAng:RotateAroundAxis(...)
curPos = LerpVector(1 * FrameTime(), curPos, destPos)
curAng = LerpAngle(1 * FrameTime(), curAng, destAng)
return {
origin = curPos,
angles = curAng
}
end)
timer.Simple(3, function()
print("Current Pos: " .. tostring(curPos) )
if origin == destPos and angles == destAng then
hook.Remove("CalcView", "CalcInterfaceView")
end
end)
end)
[/LUA]
If you use lerp it will never actually equal your desired position and angles, because you can divide by 2 infinitely. You need to round your numbers at least
[Sp]also use sharex not gyazo [/sp]
Sorry, you need to Log In to post a reply to this thread.