I'm trying to make a delimitation with vectors to form a square, and I wanted to know how I would go about doing something like if the player is between these vectors, then do blablabla. Sorry if this is confusing, don't know if this is even possible.
EDIT: I realize I could use a Vector:Distance thing, but I was wondering if the delimitation thing would still be possible.
This maybe?
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexac6c.html[/url]
Edit: Disregard this; use Internet1001's method.
No, too expensive, just use [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector:WithinAABox[/url]
[QUOTE=Internet1001;44833551]No, too expensive, just use [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector:WithinAABox[/url][/QUOTE]
Ah thanks, should be useful in the future.
Yes, it should be very possible. Check this out:
[CODE]
function PlyInVectors(ply, Vec1, Vec2)
local tmppos = ply:GetPos()
if Vec1.z > Vec2.z then
if tmppos.z > Vec1.z or tmppos.z < Vec2.z then
return false
end
else
if tmppos.z > Vec2.z or tmppos.z < Vec1.z then
return false
end
end
if Vec1.x > Vec2.x then
if tmppos.x > Vec1.x or tmppos.x < Vec2.x then
return false
end
else
if tmppos.x > Vec2.x or tmppos.x < Vec1.x then
return false
end
end
if Vec1.y > Vec2.y then
if tmppos.y > Vec1.y or tmppos.y < Vec2.y then
return false
end
else
if tmppos.y > Vec2.y or tmppos.y < Vec1.y then
return false
end
end
return true
end
[/CODE]
Edit:
Ninja'd. Use VectorWithinABox like the person above suggested.
Alright, thanks alot for these! :) I'll test these later whenever I got time to work on my stuff
Sorry, you need to Log In to post a reply to this thread.