So this may sound simple, And it probably is but for the life of me I cannot figure it out.
I Want it so when I spawn an entity(with code) it will spawn at the players looking position and will not be click into the wall. Also if they are looking to far away then just spawn it in front of the player. This is my code right now(does not work correctly)
local eyeTrace = self:GetEyeTrace() local spawnPos = eyeTrace.HitPos if spawnPos:Distance(self:GetPos()) > 150 then --This is just to make sure it does not spawn miles into the distance spawnPos = spawnPos:GetNormalized() spawnPos:Mul(150) spawnPos = self:GetPos() + spawnPos end local temp = ents.Create("item_base") temp:SetPos(spawnPos) temp:InitItem(self.inventory[slot].itemName , amount) temp:Spawn()