View Full Version : Tile Based Collision Detection
gregmax
January 15th, 2007, 12:42 AM
I am following Tonypa's Tile Based Tutorials and I have to say, they are great. His covers everything needed, except for one thing - Refering to Tutorial 9, http://www.tonypa.pri.ee/tbw/tut09.html, Stupid Enemy, I want to make this a NPC in stead of an enemy. So what do I do to make it so that I don't walk right over the enemy/NPC? I am trying to develop an RPG, and it would look silly to have the character walk on top of the NPC. Can someone provided a snippet on how to make a collision detection with the NPC and not walk on top/under the NPC?
One last favor to ask: What if I want to talk to the NPC if I am within a half tile? Would anyone be willing to share info on how this as well?
Thanks a bunch in advance
SacrificialLamb
January 15th, 2007, 05:49 AM
For my tile based collision detection I used added the name of the sprit occupying the tile to the corresponding array tile in an array that was the same size but not the map array and had my units check the array around where they are on the map for names then numbers, if names it would use a a^2=b^2+c^2 to find how far away it is... and it’s speed and if they would collide in 6 frames (but you probably would not need this last part)
duncanhall
January 15th, 2007, 07:02 AM
Take a look at the "shoot him" tutorial further down in Tony Pa's list. You can use the same function used to check whether the bullet has hit an enemy or not.
gregmax
January 15th, 2007, 11:15 AM
duncanhall - I have look at "shoot him" and I see that it removes both the enemy and bullet once the two collide. However, how I determine if the bullet is coming from above (the top of the screen), or below (the bottom of the screen), or the right and left hand side? From what I can tell it just determines if it hits the enemy in whole. I am asking because I would like my rpg game character to walk around the village without having to walk on top of the villagers, but instead needs to walk around them.
http://www.tonypa.pri.ee/tbw/tut10.html
(can you provide a small snippet of it, please?)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.