• 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!

Error with script using GML

M

Maefiosa

Guest
This is the code I was trying to do:
//UPDATE SPRITE
var _cardinalDirection = round(direction/90);
var _totalFrames = sprite_get_number(sprite_index) / 4;
image_index = localFrame + (_cardinalDirection * _totalFrames);
localFrame += sprite_get_speed(sprite_index) / FRAME_RATE;

//IF ANIMATION WOULD LOOP ON NEXT GAME STEP
if (localFrame >= _totalFrames)
{
animationEnd = true;
localFrame -= _totalFrames;
}else animationEnd = false;

When I tried to play the game to see if it was working like in the tutorial, it sent the following message:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object <undefined>:

Variable <unknown_object>.direction(8, -2147483648) not set before reading it.
at gml_GlobalScript_PlayerAnimateSprite (line 2) - var _cardinalDirection = round(direction/90);
############################################################################################
gml_GlobalScript_PlayerAnimateSprite (line 2)


Can someone please help? I do not understand what happened, I followed Shaun's Action RPG Tutorial until the second part, where this problem came from.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Top