AI_DIR:
- Code: Select all
0: Walk Up
1: Walk Down
2: Walk Right
3: Walk Left
4: Stand Down
5: Stand Left
6: Stand Right
7: Stand Up
Now heres the confusing part. I'm using angle=direction and stuff, it gets the angles correctly but finding the angle is what I'm confused on. For some reason, it works but it's all off... like if your at the center of the character and move a bit, she changes direction too soon. It's strange, but heres the code
- Code: Select all
void AIToPlayer() {
angle=direction(xscreen, yscreen, Player.xscreen, Player.yscreen);
if (angle<60) {
AI_DIR=7; }
if (angle>60 && angle<180) {
AI_DIR=4; }
if (angle>180 && angle<240) {
AI_DIR=6; }
if (angle>240) {
AI_DIR=5; }
}
angle=direction works, I even planted a text actor to test it. The issue is, I can't seem to get the angles right. I tried if (angle<90) and so on so fourth, but it would seem I need to divide 360 by 4, which is 90, but... it's so confusing because it needs to be 180° (Flat End) for each direction...
EDIT: I think I figured it out, maybe if I use if (angle<90 || angle>270) that'll create a flat 180° angle for top scanning.
Nope.. GAH I can't figure this out >.>
Edit 2:
i tried replacing with:
- Code: Select all
void AIToPlayer() {
angle=direction(xscreen, yscreen, Player.xscreen, Player.yscreen);
if (angle<90 || angle>270) {
if (x<Player.x) { AI_DIR=6; } if (x>Player.x) { AI_DIR=5; } }
if (angle>0 && angle<180) {
AI_DIR=7; }
if (angle>=180 && angle<360) {
AI_DIR=5; }
}
as to a follow up with this angle image I made after studing the angles of GE
However I still can't get it right.