Liam Earles
Member
Hey guys! So I've been play testing one of my own games and I got an error like this:
This error happens when I press the left and right arrow keys at the same time. Here's one of the codes that I have in the begin step event:
And here's the code for both the create and begin step:
If you have any idea how to fix the error, let me know. Thanks.
Code:
___________________________________________
############################################################################################
FATAL ERROR in
action number 3
of Step Event1
for object SmashF:
Variable <unknown_object>.move(100010, -2147483648) not set before reading it.
at gml_Object_SmashF_StepBeginEvent_3 (line 8) - hsp = move * movespeed;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_SmashF_StepBeginEvent_3 (line 8)
Code:
//Get the player's input
key_right = keyboard_check(vk_right) || (gamepad_axis_value(0,gp_axislh) > 0);
key_left = -(keyboard_check(vk_left) || (gamepad_axis_value(0,gp_axislh) < 0));
key_jump = keyboard_check_pressed(vk_space) || (gamepad_button_check_pressed(0,gp_face1));
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,BrownBlock))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,BrownBlock))
{
while(!place_meeting(x+sign(hsp),y,BrownBlock))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,BrownBlock))
{
while(!place_meeting(x,y+sign(vsp),BrownBlock))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
Code:
///Initialize Variables
grav = 0;
hsp = 0;
vsp = 0;
jumpspeed = 0;
movespeed = 0;
key_left = 0;
key_right = 0;
move = key_left + key_right = 0