Quantcast
Channel: Active questions tagged game-maker - Stack Overflow
Viewing all articles
Browse latest Browse all 189

The instance_create function is not working in GML

$
0
0

I am new to GMS2 and I am making a game where you are a spaceship and you have to dodge the meteors.

This is the step event for the player:

spd = 7;if (keyboard_check(ord("W"))){    y -= spd;}if (keyboard_check(ord("S"))){    y += spd;}if (keyboard_check(ord("A"))){    x -= spd;}if (keyboard_check(ord("D"))){    x += spd;}

and this is the step event of the meteor:

spd = 5;y += spd;if (y >= 765){    y = 0;    x = random_range(0, room_width);    instance_create(x+50,y,obj_meteor);}

whenever I run the program, this error shows when the meteor reaches the y value of 765:

___________________________________________############################################################################################ERROR inaction number 1of  Step Event0for object obj_meteor:Variable <unknown_object>.instance_create(100004, -2147483648) not set before reading it. at gml_Object_obj_meteor_Step_0 (line 11) -        instance_create(x+50,y,obj_meteor);############################################################################################gml_Object_obj_meteor_Step_0 (line 11)

I have been trying for 2 hours and I cant solve, any help is appreciated.


Viewing all articles
Browse latest Browse all 189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>