How to do a npc following a hero JAVA
Hello I made this game and I have an npc and I would like to make him
follow the main hero the hero has the following atributes
int x
int y (theese two are where his location is)
int smerX (where he faces can be -1 to 1)
int smerY
the npc has all theese atributes also now I tried this:
if(x == platno.hero.x || x > platno.npc.x)
{
smerx = -1;
smery = 0;
}
if(x == platno.hero.x || x < platno.npc.x)
{
smerx = 0;
smery = 1;
}
if(y == platno.hero.y || y > platno.npc.y)
{
smerx = 1;
smery = 0;
}
if(y == platno.hero.y || y < platno.npc.y)
{
smerx = 0;
smery = -1;
}
Thanks if your going to help :)
No comments:
Post a Comment