• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Fatal Error

S

SpaceKill

Guest
Hello.I'm new to gamemaker and I'm trying to make character movement (only left and right).
I've entered the neccesary code in a step event
if(keyboard_check(ord("A") ) ) {
x -= walkSpeed
image_Speed = walkSpeed / 3;
sprite_index = sprite41;

and I get this error when I press A
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object object34:

Variable object34.walkSpeed(100004, -2147483648) not set before reading it.
at gml_Object_object34_Step_0 (line 5) - x -= walkSpeed
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_object34_Step_0 (line 5)
Thank you in advance.
 
Last edited by a moderator:

rIKmAN

Member
Variable object34.walkSpeed(100004, -2147483648) not set before reading it.
It's telling you that you haven't set the variable walkSpeed anywhere in your code before you try to subtract it from x.

Have you initialised a walkSpeed variable and given it a value in the Create event?
 
S

SpaceKill

Guest
It's telling you that you haven't set the variable walkSpeed anywhere in your code before you try to subtract it from x.

Have you initialised a walkSpeed variable and given it a value in the Create event?
Yeah.
here are the values
image_speed= 0;
walk_Speed = 3.5;
 

rIKmAN

Member
I fixed it for the A key but i get this error with the D key
How do I solve this?
Thanks BTW
If it's the same error then I would assume it's the same problem - you need to use the same variable you setup in the Create Event in the code for your "D" keypress.
 
S

SpaceKill

Guest
If it's the same error then I would assume it's the same problem - you need to use the same variable you setup in the Create Event in the code for your "D" keypress.
I don't get the error anymore but when I try to move right the sprite moves left
 
S

SpaceKill

Guest
OK so think about it - why do you think that might be?

What are you doing when you press the A or D key?
Check those calculations.
woah.sorry for the late reply. I fixed all the error basically and I can finally walk in the game but there's only one small problem. I can walk with the keys A or D (left and right) but there's an error in the code or something because if I press any other keys the animation plays but the character isn't going left or right. I don't want the character to do anything if I press no key but it still does so
Help
The code
if(keyboard_check (ord("A") ) ) {
x -= walkSpeed
image_Speed = walkSpeed / 3;
sprite_index = sprite41;
}
if(keyboard_check(ord("D") ) ) {
x += walkSpeed
image_Speed = walkSpeed / 3;
sprite_index = sprite42;
}
if(keyboard_check (vk_nokey) ) {
imagespeed = 0
image_index = 0
walkspeed = 3.5
}
if(keyboard_check (vk_shift)) {
walkspeed=7
 
Every single 'error' in this thread, including the last one you posted (is image_Speed and imagespeed the same thing? No...), is you spelling things wrong. Read your damn code over before posting. If each variable is not exactly the same each time you've typed it out, correct it. You _cannot_ be sloppy or lazy with typing when programming.
 

woods

Member
i spend more time going back over and over... changing the CAPS and the _UNDERSCORE_

you will find that happens alot... same with lower case l and capitol I ... ok that one might be a legit misread... but you get the point

pick one style of obj_word_Structure and stick with it.. it will help in the long run..

things like naming objects " Owall " or "obj_wall" or ObjectWallPieceLeft or whatever format you like.. make it a habit to use that_same_typing_format ... that alone will save you hours of headache.

personally i try to name all my objects with "obj_what_Ever" if its object it starts obj_ if it has more than one word, its underscore and caps on the first letter of each word..
if its a sprite, same thing spr_what_Ever
if its a script... yep.. scr_What_ever

consistencyandattentiontodetail is a must have ;o)
 
Top