L
x + sign(hsp)
instead of just x + hsp
, because I guess you want to move your object 1 pixel at a time until you collide with your wall (which you know is within hsp
distance, according to line 23).That's what it seems like at a first glance. What's actually happening is that OP is attempting to read y, a default instance variable, in a script. That is, directly in a script, without wrapping it in a function. Scripts run at a global scope, and the global scope doesn't have a y variable, so that's a one-way trip to spontaneous combustion land.I might be wrong, but it seems you're running your code inside a Create event, according to the error message. I don't know if we're allowed to use the collision functions in Create event (I wish I could verify it now but I'm not home at the moment ... office work... ). Instead, maybe run your code in the Step event and just do some initializations in the Create event.