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

GML code problems from Shaun Spalding's Your first game pt3

S

shadowelite7

Guest
Earlier today I was watching the pt3 tutorial for enemies. I did everything correctly but I received errors. I rechecked if I had everything correct but I still received errors.

Here is the code along with the syntax error message.

Code:
obj_enemy Event: Create at line 2, 1 : variable spd only referenced once
obj_enemy Event: Create at line 1, 1 : variable hp only referenced once

hp = 5;
spd = 1.5;
Code:
obj_enemy Event: Step at line 2, 3 : Got '{' ({) expected ')'
obj_enemy Event: Step at line 4, 3 : unexpected syntax error

if (instance_exists(obj_player)
{
    move_towards_point(obj_player.x,obj_player.y,spd);
}
image_angle = direction;
here is the video link for reference. I am at 8:44.
 

Simon Gust

Member
The first 2 errors are just warnings, you can ignore them if you're following the tutorial.
The other errors are because you didn't stack enough braces around the if statement.
If you count the ( and ) you can see that they don't add up.
 
R

Rattlejaw

Guest
You need another ")" after instance_exists(obj_player).

It should be if (instance_exists(obj_player))
 

Rob

Member
Click on brackets and curly braces and they'll show you their partners. If they show up as red, you missed one.

It's rare (impossible?) for somebody to do "everything correctly", copying a tutorial, and for their result to not match the tutorial itself.

Other mistakes you'll need to look out for are typos and not changing things properly after a copy/paste.
These are the most common mistakes.

When people have a problem with one of my tutorials, it's usually one of these issues!
 
S

shadowelite7

Guest
Thank you Rob, Simon Guest and Rattlejaw. I saw my mistake and fixed it. I don't know why I missed this but thanks for telling me.
 
Top