Stoozey
Member
So, I am pretty new to GML and I decided to make a random little project for movement and changing sprites to go with it, and whenever I move using W/A/S I get a syntax error of this:
The error above is me pressing the S key. Something I am finding strange is that when I press the D key, everything is fine and the character will move.
Here is the code, (any advice on making my code neater would also be appreciated but I mainly just need help with this )
P.S - very sorry if the resolution is very obvious, I'm trying to make a better transition into GML.
Code:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_sans:
Unable to find any instance for object index '270' name '(null)'
at gml_Object_obj_sans_Step_0 (line 44) - direction.speed = walkSpeed;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_sans_Step_0 (line 44)
Here is the code, (any advice on making my code neater would also be appreciated but I mainly just need help with this )
Code:
if(canMove = true){
if keyboard_check(ord("W"))
{
sprite_index = spr_sans_u;
isWalking = true;
direction = 90;
direction.speed = walkSpeed;
}
else if keyboard_check(ord("D"))
{
sprite_index = spr_sans_r;
isWalking = true;
direction = 0;
direction.speed = walkSpeed;
}
else if keyboard_check(ord("A"))
{
sprite_index = spr_sans_l;
isWalking = true;
direction = 180;
direction.speed = walkSpeed;
}
else if keyboard_check(ord("S"))
{
sprite_index = spr_sans_d;
isWalking = true;
direction = 270;
direction.speed = walkSpeed;
}
}
else
{
isWalking = false;
}