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

GMS2 While and If statements Error Malformed

P

Patrick Johnson

Guest
I'm having an issue with the "while" and "if" statement in my code. I run the compiler but it says that the function is malformed, regardless of whether or not I use "while" or "if". It works fine in GMS 1.4 but not GMS2.

/// Code in the game > o_enemy > create event ///

if(distance_to_object(o_player)<100);
{
x = random(room_width);
y = random(room_height);
}

///end malformation code///


It should be in the create event, but I also tried it in the step event for kicks and giggles, still no luck. The point is to get the enemy to spawn away from the position of the player so that way it doesnt stack on top and kill the player randomly. Any advice? I'm scratching my head.

Cheers
 

rIKmAN

Member
I'm having an issue with the "while" and "if" statement in my code. I run the compiler but it says that the function is malformed, regardless of whether or not I use "while" or "if". It works fine in GMS 1.4 but not GMS2.

/// Code in the game > o_enemy > create event ///

if(distance_to_object(o_player)<100);
{
x = random(room_width);
y = random(room_height);
}

///end malformation code///


It should be in the create event, but I also tried it in the step event for kicks and giggles, still no luck. The point is to get the enemy to spawn away from the position of the player so that way it doesnt stack on top and kill the player randomly. Any advice? I'm scratching my head.

Cheers
Remove the semi-colon from the end of the if line.
 
P

Patrick Johnson

Guest
and that does it. Well thank you. Sometimes the semicolon gets the best of us XD
 
Top