Garry's Mod Wiki

Revision Difference

util.IsInWorld#529598

<function name="IsInWorld" parent="util" type="libraryfunc"> <description>Checks if a certain position is within the world bounds.</description> <realm>Server</realm> <args> <arg name="position" type="Vector">Position to check.</arg> </args> <rets> <ret name="" type="boolean">Whether the vector is in world.</ret> </rets> </function> <example> <description> Here's a trick you can do to achieve the behavior of this function on the client. (This may be less efficient than the serverside function itself) </description> <code> local tr = { collisiongroup = COLLISION_GROUP_WORLD } local trOut = {} local tr = { collisiongroup = COLLISION_GROUP_WORLD, output = trOut }⤶ function util.IsInWorld( pos ) tr.start = pos tr.endpos = pos return util.TraceLine( tr ).HitWorld⤶ util.TraceLine( tr )⤶ ⤶ return trOut.HitWorld⤶ end </code> </example>