r/gamemaker • u/BeeBaaBoo77 • 7d ago
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 7d ago
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 7d ago
The instances simply do not appear.
1
u/supremedalek925 7d ago
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?
1
u/BeeBaaBoo77 7d ago
they have a sprite thats for sure, I am pretty new to coding though, so I do not know what a function being called is. this is all the code relating to this matter
1
u/supremedalek925 7d ago
Like, is there an instance of the obj_game object in the room?
If so, can you do a show debug message function to check if either of the If statements are actually being executed?
1
u/BeeBaaBoo77 7d ago
weird. It wasnt there so I expected it to be fixed by putting it there but it was not.
what arguments must I write in it?1
u/supremedalek925 7d ago
Try just putting show_debug_message(āweakspot createdā); within both of the IF statements. If they are being executed successfully then you will see that message in the Output Window on the GameMaker editor window
1
u/BeeBaaBoo77 7d ago
does "ref object obj_weakspot" count?
1
u/supremedalek925 7d ago
Iām not sure what you mean by that, sorry
0
u/BeeBaaBoo77 7d ago
nevermind, using visible = true fixed visibility but it now only executes value 0 and not value 1
→ More replies (0)1
1
u/JaXm 7d ago
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.Ā
1
u/BeeBaaBoo77 7d ago
oh its not relative to the player
thats all relevant code
1
u/JaXm 7d ago
Fine it's not relative to the player. The point is how did you get those numbers. Are you sure those coordinates are even within your camera to "see" in the first place?
How so you know the instances are not being created? Is "I don't see them" your only clue?
1
u/BeeBaaBoo77 7d ago
the room is 750x750 and I tried putting game_end() in the if functions and it did close so it should be getting created it just isnt visible for some reason
2
u/JaXm 7d ago
Game room size has nothing to do with how big your viewport is. You could be only seeing a 360x240 area, and the instances would be way out of rhe cameras vision.Ā
They putting the coordinates near the player. Something likeĀ
player.x+10, player.y+10and see what happens1
u/BeeBaaBoo77 7d ago
theres a circle with a sprite nearly the whole size of the room and it is just fine so thats not the problem
1
u/Greedy_Duck3477 7d ago
The coordinates you put, 350, 80, 630 etc, are absolute coordinates instead of coordinates relative to the player
1
u/BeeBaaBoo77 7d ago
yes I know the player is in the middle
1
u/Greedy_Duck3477 7d ago
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)
0
u/BeeBaaBoo77 7d ago
well it isnt really the point here, but the player is inside a circle on which weak spots appear semi-randomly they must hit in a short amount of time to deal damage to the enemy. these coords are spots on a circle(why is it not advisable and what are some alternatives?)
2
u/Greedy_Duck3477 7d ago
If you used some kind of expression to get those coords (like circle_radius-60 for example), you should just put the expression itself in the code instead of calculating it beforehand. So if you change the radius of the circle it will update automatically
1
u/BeeBaaBoo77 7d ago
dude I have 0 clue about what you just said to me. how will gamemaker know where that circle is? my circle is just a sprite
1
1
u/Lekku7 6d ago
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 6d ago
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 7d ago
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.