PDA

View Full Version : NPC XY Coordinates



theGoronKing
02-26-2007, 06:07 PM
I believe it is possible to change the XY coordinates of an NPC, all I ask is what is the variable called, and is it possible to manipulate it?

EDIT: Never mind, but is there a way to retrieve the NPC's direction/distance from Link?

Saffith
02-26-2007, 07:50 PM
There's no built-in function for that. Here's the distance function, though, in case you don't know it:

float Distance(float x1, float y1, float x2, float y2)
{
return Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
Then the distance is just Distance(Link->X, Link->Y, NPCPtr->X, NPCPtr->Y).
As for the direction... Well, there are a few different ways you could find that, depending on what you're trying to accomplish. If you just need up/down/left/right, the easiest way is just to compare the X and Y values. If you need a precise angle, though, you'll probably have to bring trigonometry into it.
Hm... I'm pretty sure there's no arctangent function at the moment, though.