Detecting if for k,v in pairs() finds world?

Example(for k,v in pairs(ents.FindInSphere(Vector(0,0,0), 500)) do) returns all the entitys it finds in a sphere and with in 500 units of the center of the map, except it ignores the world. How can i know if the world is in certain distance of an entity. I mean tracers detect world. Why cant for k,v in pairs()?

It’s not as easy as you think. FindInSphere simply looks for entities whose origin is at a given distance from the center. The world’s origin is located at 0,0,0. See what’s happening?

Why do you need to detect the world? Your best bet would be to use **[Util.TraceHull](**, it’s like a trace but instead tracing from a single point, it traces from a box. It’s not a sphere but it’s better than nothing. Perform a tracehull from the position you want to check, and in any direction you want, it doesn’t matter, if the trace result has StartsSolid set to true, then you got it.

It’s better then a sphere, they use so many more traces. (Something like 129,600 traces)

Better in terms of performance, obviously, but not necessarily better for what he needs. But in most cases, a box does nicely.

Thanks, gonna try that.

And I actually needed something more of a box shaped ents.FindIn. FindInSphere was somewhat of an example. So was starting from Vector(0,0,0). Anyway, thanks.

I don’t get why it needs to use traces. Just check the distance between the entities, since a constant distance would make a sphere anyway. Obviously wouldn’t work with the world.

I thought it did traces on every degree around it. I may be wrong though (since that seems like a much better way to do it)