Axl Trauts
Member
Hi,
I am having a weird issue: When checking if the shark object player object is away from the player (to charge if closer), the IF statement runs even if the statement is false. The original relevant part of the Step event code on the Shark object is this:
Note that the Player's Y variable is stored on a global variable on a persistent object. I checked, it ALWAYS shows the same value as Y. However, the IF statement runs even if the expression is actually false. So I tried just using the Y variable and somehow it works. I checked drawing the player's Y variable, the global variable, the expression shows 0 if distance > 300 (Of course variable dista wast not local for the draw_text function to work). See attached files.
Why? I am not sure. I solved the issue but this bugs me.
This makes me wonder if IF expressions might have some issues checking global variables.
I am having a weird issue: When checking if the shark object player object is away from the player (to charge if closer), the IF statement runs even if the statement is false. The original relevant part of the Step event code on the Shark object is this:
GML:
var dista = point_distance(x,y,x,global.var_player_y);
if (dista <= 300 && locked == 0)
{ locked = 1;
speed = 5;
}
GML:
var dista = point_distance(x,y,x,obj_player_p1.y);
if (dista <= 300 && locked == 0)
{ locked = 1;
speed = 5;
This makes me wonder if IF expressions might have some issues checking global variables.
Attachments
-
28.3 KB Views: 5
-
46.7 KB Views: 5