Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Quickly retrieving entities by position


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 lride   Members   -  Reputation: 633

Like
0Likes
Like

Posted 31 May 2013 - 09:04 PM

In a tower defense game for example, I want to get all the entities within a splash tower's range. How is this usually implemented?


An invisible text.

Sponsor:

#2 frob   Moderators   -  Reputation: 22285

Like
0Likes
Like

Posted 31 May 2013 - 09:45 PM

Depends entirely on the game.

Most major 3D games use a spatial tree, such as a loose quadtree, and store object IDs in there. When an object is moved the corresponding entry gets updated. Queries for overlappinng areas of a spatial tree are extremely quick and will return a collection of object IDs.

If your game is tiny and you only have a few dozen or even a few hundred objects and the checks are rare, a simple brute force check to get the squared distances may be more than adaquate.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS