I am just clueless at the moment I having a weird acting enemy in my game. The enemy needs to walk from waypoint A to B to C to D and back to A. This is going good when I just say that he needs to walk from A to B or B to C or C to D or D to A. But now it comes the enemy needs to make a round kind of a patrol round. So he needs to be able to make a turn this is also not a big problem from A to C or D to B but when I want him to move from B to D or C to A he just hangs at the first waypoint he is stuck.
As far is I debuged it and can see the problem it is only when the enemy had to move in the z -=3.0 direction. he does this not in the z +=3.0. I debuged it further so I can see where he is stuck and he is stuck between v.X < t.X and v.X > t.X.
I can understand that you cant understand this whole story above so here is a some code.
Code: Select all
void MoveEnemy()
{
v = enemy->getPosition();
if(v.X < t.X)
{
printf("v.X < t.X \n");
v.X +=3.0;
enemy->setPosition(v);
enemy->setRotation(vector3df(0,0,0));
}
else if (v.Z < t.Z)
{
printf("v.Z < t.Z \n");
v.Z +=3.0;
enemy->setPosition(v);
enemy->setRotation(vector3df(0,-90,0));
}
else if(v.X > t.X)
{
printf("v.X > t.X \n");
v.X -=3.0;
enemy->setPosition(v);
enemy->setRotation(vector3df(0,180,0));
}
else if(v.Z > t.Z)
{
printf("v.Z > t.Z \n");
v.Z -=3.0;
enemy->setPosition(v);
enemy->setRotation(vector3df(0,90,0));
}
}