• Need help with ply:SetPos() and ply:GetShootPos()
    7 replies, posted
Hey, I've been having issues with SetPos and GetShootPos. It teleports the player to their actual eye position, like, the position of their actual, ingame eyeball. Not their view point. It's a problem with GetShootPos and EyePos. I've tried printing their shoot pos, doesn't return anything suspicious. I've tried: ply:SetPos( ply:GetShootPos() ) ply:SetPos( ply:EyePos() ) fml = {} fml[1], fml[2], fml[3] = ply:GetShootPos() ply:SetPos( Vector( fml[1], fml[2], fml[3] ) ) None have worked, they all teleport me to, basically, my head.
Do you mean you want to teleport them to the spot they're aiming at? If so, you'll need to perform a trace with Player/GetEyeTrace and set their position to that.
Firstly, which realm is it? (SERVER / CLIENT)
Entity/EyePos, Player/GetShootPos, Player/GetEyeTrace ply:SetPos(ply:GetEyeTrace().HitPos)
Do note the above are going to fuck up when aiming at a ceiling or a wall. local function TeleportToAim(ply)     local plyMins,plyMaxs=ply:GetHull()     local t = {         start = ply:GetShootPos(),         endpos = ply:GetEyeTrace().HitPos,         maxs = plyMaxs,         mins = plyMins,         filter = ply,         mask = MASK_SOLID,         collisiongroup = COLLISION_GROUP_WEAPON,         ignoreworld = false     }     local tr =util.TraceHull(t)     ply:SetPos(tr.HitPos) end
have fun aiming through holes
local t = {     maxs = plyMaxs,     mins = plyMins,     filter = ply,     mask = MASK_SOLID,     collisiongroup = COLLISION_GROUP_WEAPON,     ignoreworld = false } local function TeleportToAim(ply)     local plyMins,plyMaxs=ply:GetHull()     local et = ply:GetEyeTrace()     t.start = et.HitPos     t.endpos = et.HitPos + et.HitNormal * 64     local tr1 = util.TraceLine(t)     t.start = tr1.HitPos     t.endpos = et.HitPos     local tr2 = util.TraceHull(t)     ply:SetPos(tr2.HitPos) end
maxs = plyMaxs, mins = plyMins, This variables are nil, because weren't set
Sorry, you need to Log In to post a reply to this thread.