Player Traceline

I have an addon that replaces sprays with a emblem the user creates and I’m attempting to make it if they are looking directly at the emblem it prints the sprayers name in chat. But when I use eyetrace it doesn’t count the sent as an ent ?

When looking at the sent all it prints is “worldspawn” when it should be printing “sent_emblem”. I feel like this is a problem with the entity and not my trace code? Anyway to solve this?



hook.Add( "Think", "EmblemTracer", function()

	local ply = LocalPlayer()

	local trace = ply:GetEyeTrace()

    print( trace.Entity:GetClass() )

end)


Not sure on the rules for bumping, But I would appreciate a reply.

Are you sure the emblem is an entity? This seems strange

Edit: Try this just to be sure https://wiki.garrysmod.com/page/ents/FindByClass

If your ent doesnt have a physic object, then traces wont work with it

I’ve attempted to set its physics but it still returns “worldspawn”



function ENT:Initialize()
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )

    local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
end


It wont have a collision model, thats why it returns worldspawn