Page 1 of 1

Best way to find closest object

Posted: Tue May 12, 2015 4:47 pm
by Chaz
Hey. Actually i'm working on online game with physics on server side. There are players and mobs. I want to implement agro system of aggression for mobs.
It means that when some player is nearing to mob at certain distance - mob have to start hunt on player.
What is the best way to implement it? Just checking distance between mob and each players or using something like a trigger?
p.s. sry for my bad English

Re: Best way to find closest object

Posted: Tue Jul 21, 2015 2:03 pm
by benelot
From what I think, your distance test is by far the most easy option and also the most efficient. Just check the distances between two objects and if it falls below a certain threshold, change to the aggression policy of your mob. At least that is what I did in one of our games. Doing raycasts would only make sense if you would be interested for an object in a certain direction.