Jump to content
  • Advertisement
Sign in to follow this  
Butterman

NPC Collision Detection

This topic is 4174 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey. Ive got aggressive NPCs that attack the player if the player comes within a certain square around the NPC (Once the NPC has "seen" the player it will chase him forever). It then follows the player. It finds on which axis the player is further away (X or Y) and move in that direction. (I didnt want them moving diagonnally) This all works fine. But the problem comes when the NPC is on another side of an un-passable object. The NPC walks right through it. Ive tried getting around this by stopping the NPC on a collision. Then making it decide which direction to go from the position of the player. But i have not been able to get even this to work. For example
      
      X (Player is closer on the right. So go right until you can go down)
  =======

       P

P = Player
X = Baddie



But this wont work where
  |======
  |      
  |  X   
  |=======
   Y

The NPC will just go left into the wall and will get stuck.



Note that information is storred in tile maps. What do you suggest?

Share this post


Link to post
Share on other sites
Advertisement
For this kind of thing is would probably be best to use pathfinding.

There is some decent info on the subject here

Regards,
ViLiO

Share this post


Link to post
Share on other sites
Movements arent done tile by tile. But pixel by pixel. So would using the same algorithm for pixel by pixel work? Or would it be a big slow down?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!