Well, I figure I'll ask here and get some opinions before I implement this the wrong way and frustrate myself...
What is the best way to handle multiple enemies? Let's say in my server I do this :
createNewEnemyNode()
{
EnemyNode* eNode = new EnemyNode();//it's a class, it contains the health int.
eNode->Mesh = blahblah...etc.
}
Now let's say a player damages this 'EnemyNode' but there are four others currently spawned. How will I remove it from this class' health integer and not all four others. Would it automatically know which because a 'new class' is created for each entity?
Thanks in advance...
Handling enemies
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Yes but the ID would (after some time) get too high and hit that certain limit that s32's or int's or whatever I use has 
Then again, that'll never happen. I don't think I should have to do too much since each enemy is a new version of the class..
But I may be wrong, I'll assign ID's as well, though how would I use that to detect who was hit and how much to subtract?
Then again, that'll never happen. I don't think I should have to do too much since each enemy is a new version of the class..
But I may be wrong, I'll assign ID's as well, though how would I use that to detect who was hit and how much to subtract?
As far as the problems with the id's getting too high, don't worry about that. Just start re-using the ID's after the enemies have died and their nodes have been deleted.
You could just do some picking to find which nodes are the ones being hit, and using their ID's to remove health. Depending on what type of attacks your players will be doing, you could just use bounding boxes, or hitboxes (if you're using a physics engine).
You could just do some picking to find which nodes are the ones being hit, and using their ID's to remove health. Depending on what type of attacks your players will be doing, you could just use bounding boxes, or hitboxes (if you're using a physics engine).
-
monkeycracks
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact: