Best way to find closest object

Post Reply
Chaz
Posts: 44
Joined: Mon Jan 12, 2015 1:36 pm

Best way to find closest object

Post 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
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Best way to find closest object

Post 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.
Post Reply