Brush entitys ent:GetPos()


normaly you should use ent:GetPos()
but as it seems, when i use it at brush based entitys, it dont work it returns vector(0,0,0

made brush whit trigger matrial, then tie to entity and then enterred my entity name.
it works since perfecly,

but now i need to get the pos of that entity, else i would need to make an keyvalue wich contains the text x y z but to do that in 17 maps for about 10-40 entitiys, a BIT hard.

and there should be an easy way

any one know this?


to hard i guess?

Try this:

[lua]local min, max = ent:WorldSpaceAABB()
local pos = (min+max)/2[/lua]

sorry for the bumb, but i still cant get it to work :frowning:


What are you trying to do exactly?

to get the pos of an entity.

its a brush

hammer > placed a box whit trigger matrial> tie to entity > called it info_test_ent
lua > ent:GetPos() returns vector(0,0,0)

Did you try this?

This is correct. But I advise against division, multiplication is faster.

local mins, maxs = ent:WorldSpaceAABB();
local pos = ( mins + maxs ) * 0.5;

i tryed that, and lol! it must be faster about 0.00000000000001 second?XD

Oh, never really paid attention to that, but now that you say it, it’s pretty obvious. :v: Thanks for the tip.

still no solusion :frowning: bump

Does info_test_ent exist? Do you have red text in console saying it doesn’t exist?

GetPos is valid on any ent.

Read the OP again, he said it returns 0,0,0.

What does the WorldSpaceAABB solution return? You should be a bit clearer, does it still return 0,0,0 or what?
Because it always worked for me.

it returns 0,0,0 also, and the ent name i just tyoped in something random, it real ent exists.

after trying it for a while, its about random what the obbspace thngy returns, 0,0,0 or the good pos its totaly random, tryed to remake my hole dedi server, tryed t in my GMod
else said. my pc is fucked XD

wel, thanks any way for your time guys.