• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

Having trouble with an error

T

tatamuncher420

Guest
I am kinda stumped here and I don't know where to go from here any assistance would be greatly appreciated
my code:
1: //Player Movement
2:
3: var xDirection, yDirection;
4: xDirection = keyboard_check(ord('D')) - keyboard_check(ord('A'));
5: xDirection = keyboard_check(ord('S')) - keyboard_check(ord('W'));
6:
7: x += xDirection * 5
8: x += yDirection * 5

The Error:

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

local variable yDirection(100002, -2147483648) not set before reading it.
at gml_Object_obj_player_StepNormalEvent_1 (line 8) - x += yDirection * 5
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_player_StepNormalEvent_1 (line 8)
 

Dog Slobber

Member
yDirection doesn't have a value.

should line 5 be:
yDirection = keyboard_check(ord('S')) - keyboard_check(ord('W'));

And while we're at it, should line 8 be:
y += yDirection * 5
 
Top