Variable not set before reading it

qwertyui

Member
Hello everyone.
I'm having an error programming the character's movement.
I LITERALLY CANNOT MAKE HIM WALK AT ALL.
The movement I want to do is in rpg style.
I spent 30 minutes copying a tutorial code from youtube, this part is literally IDENTICAL.
But here is my code:

#region Horizontal collision
if place_meeting(x+hspd, y,obj_wall) {
while !place_meeting(x+hspd,y,obj_wall){
x += sign(hspd)
}
hspd = 0;
}
x+= hspd;

This is a part of a collision script that is together with the movement script.
but this error won't let me test the game.
If anyone can explain to me what the hell is going on please explain to me.
 

TsukaYuriko

☄️
Forum Staff
Moderator
If we were playing Not-Reading-Sticky-Topics Bingo, you'd have three out of three things to check now... :)



 

Nidoking

Member
while !place_meeting(x+hspd,y,obj_wall)
Literally identical? Exactly? Character for character? This exact line is in your tutorial? I would like to see this tutorial and the line in question so I can tell whoever made it why they are wrong so they don't spread this problem to anyone else. Unless, maybe, you actually didn't copy this exact line correctly and might be able to find your mistake by comparing it to the tutorial.
 
if place_meeting(x+hspd, y,obj_wall) {
while !place_meeting(x+hspd,y,obj_wall){
x += sign(hspd)
}
hspd = 0;
}
So the code you have there says:

GML:
if something is happening
    {
    while that thing is NOT happening
        {
        // It's literally impossible for this to occur
        x += sign(hspd)
        }
    }
 

Gamebot

Member
What does the error say? I'm guessing something like hspd and/or vspd?
Change these to vsp and hsp?

I think you should post the error or more code. Include the create and step events in full if posting the code
 
Top