I have a little problem with my Platformer

J

Janfer

Guest
I have used this code


//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);

//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}

//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;



But it says this when I try to open it, any fast fixes? my player is named Opj_dud

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object Obj_dud:

Variable Obj_dud.obj_wall(100011, -2147483648) not set before reading it.
at gml_Object_Obj_dud_StepNormalEvent_1 (line 11) - if (place_meeting(x,y+1,obj_wall))
############################################################################################
 
Have you got an object in your game called obj_wall? Remember, in code it must be referred to exactly as it is in the resource tree (like how you can't reference Obj_dud as obj_dud).
 
Top