I've tried a variety of different ways, but they all seem inconsistent so I'll just show and ask. I'm trying to detect the player on an npc, which really seems easy enough but for some reason acts very strange with this code.
PHP Code:
if (player.x > this.x && player.x < this.x+2 && player.y > this.y && player.y < this.y+2)
Now I am doing this check in a timeout and clientside, and yes I did set a timer. What I see it doing is checking for the player inside these positions.
What it actually does is, sometimes it checks for the player.
My Timer is set at .1 so that's not the problem. Also i've played with the plus and minus from the this.x and this.y, but it just seems that it doesn't always catch the player on top of the npc which would be these coordinates.
Any suggestions would be awesome.