K
KakuniProject
Guest
Hello everyone, I'm quite new to game maker and into programming. I recently started a game and I'm on the first steps creating the collisions and movements,
the collisions it was working fine when I inserted into step/Object, however now I tried to add into a script .
I simply copied and pasted my code into my script, and did not work for some reason it is sayin is a problem on line 3. I tried everything and couldn't fix the problem.
I will attach a screenshot of my code that I'm trying to add on script, also I will add my code below. I would highly appreciate if someone help me and I am deeply sorry if I didn't post this question in the right question.
Thank you very much.
My collision code below;
//Calculate Collision Horizontal
if(place_meeting(x+hsp,y,OinvisibleGround))
{
while(!place_meeting(x+sign(hsp),y,OinvisibleGround))
{
x = x + sign(hsp);
}
hsp = 0
}
x = x + hsp;
//Calculate Collision Vertical
if(place_meeting (x , y + vsp ,OinvisibleGround))
{
while ( !place_meeting (x, y + sign (vsp) ,OinvisibleGround))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Jumping Movement
if (place_meeting(x,y+1,OinvisibleGround)) // To recognise if standing on ground:
{
jumps=jumps_max;
}
if (key_jump) && (jumps > 0) //If you jump and jump variable is = to more than 0, Jump and subtract -1 from jumps
{
jumps -= 1;
vsp = jump_height;
}
The error is ;
ERROR in
action number 1
of Create Event
for object <undefined>:
Variable <unknown_object>.y(1, -2147483648) not set before reading it.
at gml_GlobalScript_movement_calculation (line 3) - if(place_meeting(x+hsp,y,OinvisibleGround))
############################################################################################
gml_GlobalScript_movement_calculation (line 3)
the collisions it was working fine when I inserted into step/Object, however now I tried to add into a script .
I simply copied and pasted my code into my script, and did not work for some reason it is sayin is a problem on line 3. I tried everything and couldn't fix the problem.
I will attach a screenshot of my code that I'm trying to add on script, also I will add my code below. I would highly appreciate if someone help me and I am deeply sorry if I didn't post this question in the right question.
Thank you very much.
My collision code below;
//Calculate Collision Horizontal
if(place_meeting(x+hsp,y,OinvisibleGround))
{
while(!place_meeting(x+sign(hsp),y,OinvisibleGround))
{
x = x + sign(hsp);
}
hsp = 0
}
x = x + hsp;
//Calculate Collision Vertical
if(place_meeting (x , y + vsp ,OinvisibleGround))
{
while ( !place_meeting (x, y + sign (vsp) ,OinvisibleGround))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Jumping Movement
if (place_meeting(x,y+1,OinvisibleGround)) // To recognise if standing on ground:
{
jumps=jumps_max;
}
if (key_jump) && (jumps > 0) //If you jump and jump variable is = to more than 0, Jump and subtract -1 from jumps
{
jumps -= 1;
vsp = jump_height;
}
The error is ;
ERROR in
action number 1
of Create Event
for object <undefined>:
Variable <unknown_object>.y(1, -2147483648) not set before reading it.
at gml_GlobalScript_movement_calculation (line 3) - if(place_meeting(x+hsp,y,OinvisibleGround))
############################################################################################
gml_GlobalScript_movement_calculation (line 3)