• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - GML Visual instance_create_layer :: specified layer "Gun" does not exist

C

ColeusSanctus

Guest
Hey Guys,
first of all, I am not a pro and this is one of my first projects.
Thats why I use Drag and Drop and not GML.
Now I wanted to give my objects diffrent layers, so I created new sublayers and renamed them.
I want that the spaceshuttle has the biggest depth then come the bullets and then the gun.
But every time I want to create the gun on one of my added layers this error pops up and I dont know how to fix it.
If I say the gun should be created on the normal "Instances" layer it works, but in this case my spaceshuttle is in front of the gun.
So how should I solve it?
I hope that u can help me and if there are any questions (I think so :)) please ask.GM 2 Layer_Error.JPG
Greetings, Simon
PS: Sry for my bad english :D
 
Is "Gun" a layer you have manually created in the room editor before running the game?

Are you 100% positive the code above is running in the same room that has the "Gun" layer?

If so, it might be a bug. You said you created "sub-layers".

What if you just create a main layer / top layer called "Gun". Does it work then?
 
C

ColeusSanctus

Guest
Hey,
yeah I created the Layer "Gun" manually in the room editor and I am pretty sure the code is runnning in the same room, because the code is part of the object0 (spaceshuttle) which I dragged in the room (room0).
Can I see where my code is runnning or change his location?
Also it is indifferent if I use main layers or sub-layers. It doesnt work :(
Reloading or restarting also doesnt help.
My current layers:
GM 2 Layers.JPG
 

NazGhuL

NazTaiL
Try
Code:
var tmp_layer = layer_get_id("Gun");
instance_create_layer(x, y, tmp_layer, object);
(I use global.variable for layers created in the IDE.
 
I dont normally use DnD - but I just tried setting up a test here:
upload_2017-6-10_0-14-11.png

And it works ok on my build - just a simple project, one room, two objects, first object in room with create code that creates second object.

Added a layer manually called "Gun" to the room as a sub-layer of Instances.

No errors.

What version of the IDE and runtime do you have?

Have you tried deleting the layer and re-creating it?

Have you tried creating a new blank project and seeing if you still get the error (using a test like I did above)
 
C

ColeusSanctus

Guest
Hey,
@NazGhuL : Sry, how can I integrate your code in my Drag and Drop version? :confused:
@IndianaBones : IDE and runtime in the picture below ( I juste the Steam version)
Deleting and re-creating doesnt solve the problem, tried it many times. ^^
I tried a new project and there it works perfect, so maybe I any wrong settings in the current project.... I dont know....
I think it would be the best if I restart my project and reprogramm it :/
GM 2 runtime&Version.JPG
PS: While watching my picture I recognized, that I dont use the current version... maybe I should update it xD
 
Definitely update the runtime.

If it works on a new blank project...hmmm...its either a bug....or there is something else happening in your project that deletes the layer and/or you are in a different room that doesn't have that layer.

Do you have any other rooms in your project that don't have the Gun layer?
 
C

ColeusSanctus

Guest
Runtime is update, nothing changed.
Yeah I have an other room without this layer.
I deleted the other room now and it works..... yay ^^
But why it hasnt worked before???
Can you give me a hint what I did wrong to prevent this in future?
Anyway, thank you for your help!
 
What position was the other room in your resource tree? Was it the first in the list? And did it have the object0 placed in the room?

If it did, that would explain it, because GameMaker always starts a game by running the first room listed in the resource tree.

And perhaps that first room didn't have the Gun layer in it.
 
C

ColeusSanctus

Guest
Well, the other room was above the main room and I tested out how to create a path.
Of course there wasnt any layer named "Gun" or "Bullet" and because I dragged the object0 in, it struggled.
I think I understand it ^^
Thanks your help!
 
Top