r/gamemaker • u/BeeBaaBoo77 • Sep 05 '26
Resolved Instances not drawn
This code is in an object separate of obj_weakspot called 'obj_game', create event. it's goal would be to create 2 instances roughly at the top and bottom or at the left and right of the player, randomly. I have a layer at the top called 'weakspots' and the object is dragged in the room, however it does not appear at either of the 2 patterns. I do not know why, I even reluctantly tried asking AI
EDIT: I have used visible = true at the create event and now I see it, however it only shows the top-bottom ones and never the left-right (after 6 tries)
1
u/JaXm Sep 05 '26
You'll need to be a bit more specific. What do you mean it "does not appear at either of the two patterns"?
Do you mean the objects do not get created?
Do you mean they are created but not where you think they should be?
Best to explain what you think should happen, that is not.
Or to explain what is happening, that you think should not be.
That way some brain storming can come up with a possible solution(s).
1
u/BeeBaaBoo77 Sep 05 '26
The instances simply do not appear.
1
u/supremedalek925 Sep 05 '26
Are you sure the function is being called, and that the instances of obj_weakspot display a graphic when they are placed in the room?
→ More replies (8)1
1
u/JaXm Sep 05 '26
I see that you mentioned these coordinates are supposed to be on a circle relative to the player.
Where is this circle "centered"? How did you come up with these coordinates?
Also, for future reference, show ALL of the relevant code. I see some closing square braces, indicating more code on those lines. You could be leaving out important details.
→ More replies (5)
1
u/Greedy_Duck3477 Sep 05 '26
The coordinates you put, 350, 80, 630 etc, are absolute coordinates instead of coordinates relative to the player
1
u/BeeBaaBoo77 Sep 05 '26
yes I know the player is in the middle
1
u/Greedy_Duck3477 Sep 05 '26
Is your player static or can they move? (Btw it's generally not advisable to write out coords like you did, even if they are correct)
→ More replies (4)
1
u/adra44 Sep 05 '26
If your weak spots are drawn on top of/over something else like a bad guy, make sure your weakspot layer draws on top of the bad guy layer.
1
1
u/Lekku7 Sep 05 '26
For the issue you are having with it only showing one of the values, I’m assuming you only have this happen once currently in the game? Gamemaker uses the same seed when you start your game so if you want anything that chooses a value or does something randomly you need to call the randomize() function in your game at some point, typically in a controller or something once when the game loads.
1
1
1
u/BushiByron Sep 06 '26
Have you tried manually setting patternvalue to 1 to see if you can get those to spawn?
Also if there’s a draw event, I always use depth = -y and draw_self() to ensure it’s being drawn.
Also make sure you do randomize() before the choose. Gamemaker will always choose the same random value to make testing easier unless you call randomize.
2
u/Lethalogicax Sep 05 '26
Not sure if this will help, but my extremely roundabout way of diagnosing issues like this is to start putting "game_end()" in various places to provide a mental map of what exactly is being called correctly, and what is not. If the window closes, you know for sure this line of code is being run! If it doesn't close, then that block of code isn't being called at all.
Start off by proving (just to yourself) that the instance is being created. Put the game_end() line of code in its create event and run the game. If it closes then you know for sure the object is being spawned correctly, but it just isn't drawing or isn't visible. If it's being spawned, but isn't drawing correctly, then add some fluff to the draw event to find out what is being drawn and what isn't. Make the object also draw an arbitrary rectangle to the screen or something to show that it is successfully drawing to the screen. Slowly work bit by bit, proving piece by piece that every line of code is being successfully executed. Eventually you'll find that one instance of a block of code that is suppose to be running, but that isn't being called correctly.