Need help for spawning bullets in specific locations!

Coffeli

Member
(Keep in mind i am very very new to gml and coding)

So im trying to make a bullet hell but dulled down, very simple few bullets on screen.

But im having alot of trouble using the create_instance_layer, it doesnt show up for me
I even tried adding a draw event to draw self incase that messed up

heres my code

oBullet create event:
instance_create_layer(1290, 400, "Bullet", oBullet);

draw event:
draw_self();
 

Joe Ellis

Member
Maybe try using instance_create_depth for now, and just put 0 for the depth. This is basically the old way of making an instance. Layers are useful, but make it more complicated aswell.

Or learn how layers work. I don't know how they work exactly though. I'm new to gms 2, I have a lot of experience with gml, but I only recently got gms2(.3)
 

Coffeli

Member
Maybe try using instance_create_depth for now, and just put 0 for the depth. This is basically the old way of making an instance. Layers are useful, but make it more complicated aswell.

Or learn how layers work. I don't know how they work exactly though. I'm new to gms 2, I have a lot of experience with gml, but I only recently got gms2(.3)
instance_create_depth(1290, 400, 0, oBullet);

I still cant see the object showing up when i run it, when i use instance_create_depth does it have a set size by default maybe that could be a reason?
 

Joe Ellis

Member
I don't know, sorry, have you got any other projects where the instances do show up? Or a tutorial project? You might have adjusted some setting somewhere that's messed it up. Also the coordinates seem dodgey, 1290, 400. Is 1290 within the view region?
 

Coffeli

Member
I don't know, sorry, have you got any other projects where the instances do show up? Or a tutorial project? You might have adjusted some setting somewhere that's messed it up. Also the coordinates seem dodgey, 1290, 400. Is 1290 within the view region?
I tried out the create depth and couldnt get any results either, i do have a tutorial project but i cant find out how to change the if statement to what i want, my tutorial project is a gun shooting a bullet, i want the bullet to be spawned by a timer or a button in a menu, and the coordinates are in the view region
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, the best thing to do would be to add a breakpoint to the line of code that spawns the bullet, then in the debugger step through the code a line at a time and ensure the bullet is being created. What you want to look for is to see if 1) the bullet "visible" variable is set to true and 2) make sure that the bullet isn't being created and then destroyed instantly. Those are the two main things that spring to mind talking about your issue. I don't think it has anything to do with depth or layers at this point.
 

Nidoking

Member
oBullet create event:
instance_create_layer(1290, 400, "Bullet", oBullet);
Has nobody pointed out that your code to create an oBullet is, apparently, only run when you've already created an oBullet? You need to either put the oBullet in the room, or put something else in the room that will create the oBullet. Then get rid of this Create event, or you'll create infinitely many oBullets and crash the game.
 

Coffeli

Member
Has nobody pointed out that your code to create an oBullet is, apparently, only run when you've already created an oBullet? You need to either put the oBullet in the room, or put something else in the room that will create the oBullet. Then get rid of this Create event, or you'll create infinitely many oBullets and crash the game.
as i was messing around with different codes i did notice any more bullets than 7 would lag me to 1fps, now i know its probably hundreds of bullets in the same spot aaaahaha
 

Coffeli

Member
Okay, the best thing to do would be to add a breakpoint to the line of code that spawns the bullet, then in the debugger step through the code a line at a time and ensure the bullet is being created. What you want to look for is to see if 1) the bullet "visible" variable is set to true and 2) make sure that the bullet isn't being created and then destroyed instantly. Those are the two main things that spring to mind talking about your issue. I don't think it has anything to do with depth or layers at this point.
i will try that thank youuu
 

Coffeli

Member
Okay, the best thing to do would be to add a breakpoint to the line of code that spawns the bullet, then in the debugger step through the code a line at a time and ensure the bullet is being created. What you want to look for is to see if 1) the bullet "visible" variable is set to true and 2) make sure that the bullet isn't being created and then destroyed instantly. Those are the two main things that spring to mind talking about your issue. I don't think it has anything to do with depth or layers at this point.
so i got to this point but now new problem, the bullets spawn and despawn and go to the right destination, but there must be two bullets to destroy the one in front. Like there is always a stragler bullet unless a new one is created then theres a new stragler.
 
Top