Scripts / Advice on measuring distance between entities

Author
Message
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 28th Sep 2015 23:05
I have an NPC in my game and I want his AI to detect when he is say 100 units from a tree.
Does anyone know of a specific function for this or a function that I could tailor.
If not can anyone suggest how I could code this?
ie
If NPC<100.00 from the tree entity then
do something
end
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Sep 2015 11:08
will work just like GetPlayerDistance(e) except you need to call both entities (as it doesn't include the player),
i.e. you need to know the entity number of the target to check (you can still use e for the object running the script)
the second function call ignores any height differences



life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 1st Oct 2015 00:52
Thanks Smallg - so easy when you see the answer!

Login to post a reply

Server time is: 2024-12-22 06:55:38
Your offset time is: 2024-12-22 06:55:38