SOLVED Variable not set before reading it.

Grimmlin

Member
Hey, I understand I am probably blind, but I keep getting this error.


___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object <undefined>:

Variable <unknown_object>.yaxis(100003, -2147483648) not set before reading it.
at gml_GlobalScript_move_state (line 3) - dir = point_direction(0, 0, xaxis, yaxis);
############################################################################################
gml_GlobalScript_move_state (line 3)


I have looked over my code for like an hour, and am probably just dumb, but this is my code, can I get some help?


/// move_state
// Get Direction
dir = point_direction(0, 0, xaxis, yaxis);

// Get Length
if (xaxis == 0) && (yaxis == 0) {
len = 0;
} else {
len = spd;
}

// get the speed variables
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);

// Horizontal collisions
if (place_meeting(x+hspd, y, OBJ_Wall)) {
while(place_meeting(x+sign(hspd), y, OBJ_Wall)) {
x += sign(hspd);
}
hspd = 0;
}

x += hspd;

// Vertical collisions
if (place_meeting(x, y+vspd, OBJ_Wall)) {
while(!place_meeting(x, y+sign(vspd), OBJ_Wall)) {
y += sign(vspd);
}
vspd = 0;
}

y += vspd;


EDIT:
Thank you very much. I was using outdated code. Sorry for the confusion.
 
Last edited:
Top