I am designing tower defense game similar to kingdom rush. I have creeps that attack with a sword and hero attack with a hammer. Hero has an area to guard and he can’t move out of that area.
Both units have box colliders.
As you can see both these units have melee attacks. I am trying to design the logic for these units to fight with each other.
I am using A* path finding method to move units in the game. [http://arongranberg.com/astar/][1]
**Scenario 1**
Creeps see hero and move to hero’s last known position, hero sees creep he also move to creep’s last known position. If they collide they will fight. If they didn’t collide after reaching respective positions they will check others positions and try again. Please note that I am using A* path finding to move I can’t update the positions during the move. So they will move to last known positions.
**Scenario 2**
Creeps see hero and move to hero position, hero sees another creep and move to that creep position. When the first creep reaches hero’s last position he is no longer there …
As you can see there are quite a few situations like this. I am trying to design a system where these units behave properly. I guess we need some sort of a hand shake like system to avoid problems.
I am sure many of you have done systems like this and I was wondering whether some of you can share how you handle this situation.
I will be grateful if you can you post a method or pseudocode.
[1]: http://arongranberg.com/astar/
↧