instance_create Help!

P

Player12Coconut

Guest
I was following a space shooter tutorial and in the video they used a code similar to
instance_create(room_width+40, randY, Enemy);
I found out GameMaker removed instance_create to instance_create_depth or layer but when i tried the new code it says "number of arguments expected 4 got 3. whats the code for this after they removed instance_create?
 

Lukan

Gay Wizard Freak
You need to specify the depth or layer in the new functions.
The third argument requires a layer name or id for the layer function, or a depth in the depth one.
So it's arguments are (x, y, [LAYER OR DEPTH], objectid)
 
P

Player12Coconut

Guest
I tried instance_create_depth(room_width+40, randY, 0, Enemy);
and i was able to play! But it doesn't seem to be working like the video shows. In the video there is suppose to be something coming down from the sky and it's suppose to be in random places but nothing is happening for me.
 

ZyKro

Member
I tried instance_create_depth(room_width+40, randY, 0, Enemy);
and i was able to play! But it doesn't seem to be working like the video shows. In the video there is suppose to be something coming down from the sky and it's suppose to be in random places but nothing is happening for me.
Are you running the code in the step event? And can you show us the code for the variable "randY"?
 
P

Player12Coconut

Guest
Are you running the code in the step event? And can you show us the code for the variable "randY"?
I am running the code in the alarm event because the tutorial does that. I am new to GameMaker so i don't really know how to do that and i am not sure what randY is but the tutorial said to add it.
 

ZyKro

Member
Is the alarm even being called? Because if the alarm[insert number here] = number, then it should run, but if isn't being called somewhere, then that's probably why it isn't working. Also, if I am not mistaken, randY should be the random y position that the enemy spawns in at. For your enemies to spawn, you have to set the alarm to go off in a certain amount of time and then make it repeat for the desired effect.
 
P

Player12Coconut

Guest
Is the alarm even being called? Because if the alarm[insert number here] = number, then it should run, but if isn't being called somewhere, then that's probably why it isn't working. Also, if I am not mistaken, randY should be the random y position that the enemy spawns in at. For your enemies to spawn, you have to set the alarm to go off in a certain amount of time and then make it repeat for the desired effect.
Well i want the enemies to spawn outside of the screen then come into the screen. And how do i make the alarm go off?
 

ZyKro

Member
Well i want the enemies to spawn outside of the screen then come into the screen. And how do i make the alarm go off?
To make the alarm go off, you would first put the code in the create event for the alarm to go off.
Code:
//Create Event
alarm[0] = #; //whatever alarm it is set to how fast you want the enemies to spawn in

//Alarm Event
//code where you spawn enemies at
//if you want to repeat, then do then add the code down below
alarm[0] = #;
//this will repeat the event forever creating enemies every amount of times
 
P

Player12Coconut

Guest
I found out another solution that isn't
instance_create_depth(room_width+40, randY, 0, Enemy); and it works. It seemed to be a lot easier then the other solution i tried to do so i'll just move on with this. But Thanks for the help! :)
 
Last edited by a moderator:
Top