#Issue with object layering/rendering
1 messages · Page 1 of 1 (latest)
Okay, going to need some context. When you say invisible, do you mean just in the room editor or in-game?
both
Okay, what is the current sprite of the object?
an animated book sprite.
Right, could you also share a screenshot of the current room of where it is placed?
(Or at least roughly, in accordance to memory)
Also share a related screenshot to your room layers
i can send a screenshot one sec
the highlighted obj is the book obj which should be visible but isn't.
Move the background layer below the instance layer
ok thanks lemme try
Also since you're new, I'd like to mention that this server does cater to more intermediate and advanced programmers, not beginners.
I'd highly suggest asking over there for the future. https://discord.gg/gamemaker
Do you have a draw event?
Is it drawing your book sprite
Is the object visible property unchecked?
Does your book actually exist in the room?
And no
I don't mean by the room editor
I mean in-game
instance_exists() is your friend here
show_debug_message(instance_exists(object_index_goes_here))
I mean its listed in the instances layer
how do i do that again?
I am giving you the literal keys
Put that in an object that also exists in that room, run your game
Or even just print a message inside of your book with show_debug_message(something_anything)
You're here to validate that your object does exist, and isn't disappearing by any means.
oh so in like create evnt or a script or smthing?
Preferably step
If that instance goes poof at any point, you'd be able to trace it down from there
can i just put it in the book object itself, or no?
Well fwiw, show_debug_message() is the one that matters here the most, just as long as you're getting a constant updated value
Sometimes I tend to do show_debug_message(a_counter) or something
Or a counter, or a date time, etc
I'm merely giving examples, not definite code
putting that in the book obj
ok
well im still new to gml. will i need to add onto the code or no?
show_debug_message() is the key one, but what you put inside of a_counter should be a value that counts, or changes
what i mean is show_debug_message(a_counter) will it be good on its own or do i nmeed to add something?
Lemme give you a hint ||a_counter isn't a built in variable of any kind||
Well, what do you think would happen?
Right now, if we were to run it, hypothetically?
(Don't actually run it, just sit and think about it)
probably nothing would change if it's not a built in variabel ig. I mean I'm just new to gml, not coding. I know how variables work.
Right, give it a run and see what happens then
as i thought, i got an error. I couldn't really undertsand what it said but clearly yeah I get i need to define a_counter. I dont know how to make a counter but i think I hacve an idea as to what I could do. one sec.
does that work?
Taking a step back
?
What was the error
I didn't try it yet. should i try it or no?
Not with your current code no
alr one sec
theres no error but now the uotput window is infinitley spammed with "it works i think."
sooooo technically my code works, but its still wrong.
right?
ohhh u said go back to what we had bf my bad missed that part
one sec
############################################################################################
ERROR in
action number 1
of Step Event0
for object obj_legend_book:
Variable obj_legend_book.a_counter(100035, -2147483648) not set before reading it.
at gml_Object_obj_legend_book_Step_0 (line 1) - show_debug_message(a_counter)
############################################################################################
gml_Object_obj_legend_book_Step_0 (line 1)
there
that was with just show_debug_message(a_counter).
im sorry this must be so painful for you I wish I knew more abt it lol
Yes so, you were right on needing to define a_counter. Error messages like these can be a lil hard to understand at times, but this usually means that you tried to "fetch" data from a variable (local or instance) that just doesn't exist or hold onto anything yet
The manual actually covers these in great depth too
well yeah i knew that. It's similar to python which I am pretty fluent in. It's just that I haven't learned all of GMLs custom statements yet.
I get that, I'm just pointing out the manual. It's usually a good place to dive into if you need to figure things out haha
anything that would apply to most languages i know
Now your code also works, but not what I was really aiming for
ok thanks
There was a reason why it's called a_counter
yeah i know you wanted me to make a counting thing but idk how
Okay, how do you define an instance variable?
not sure abt instance variables but I know how to assign variables to a specific object, just not a specific instance. I know how to use the object editor
still figuring out someof the rm though
So there's two ways you can define variables for an instance
- Variable Definitions (via Object Editor)
- The create event
We won't focus too much on 1 right now
For 2, all you need to do is
a_counter = 0;
In the Create Event
ohhhhhhh yeahhh that ok. by instances I thought you ment the specific instances of objects that are in the rooms.
No lol
yeah haha
Then counting is just a_counter += 1;
Now the reason why I say your code works here, is because well, it's infinitely spamming
Which is a GOOD sign that your instance exists
And wasn't just yeeted by instance_destroy or a room change
So it means that your book is probably just hidden
You don’t really need to anymore
ok
Though I’ll note this as well
so how do i make it appear?
For future reference
ok
Performing an instance_exists check for an object, in the exact same object type. The object needs to exist in order to run that code, so it’s redundant
Well we’ve established that the object visible is checked
And we have no draw events
yeah
And we already moved the background layer below the instances layer, so we know it’s not due to the background covering it
So, there’s only two big culprits
- The sprite set isn’t what it’s supposed to be set
- It matches the background colour
it doesn't match the background color except for the last frame which is the end of a fade out but it should start on the first frame a even checked that. it must be the sprite set thingy then but either i haven't learned that yet, or I know it and just didn't know the name.
yes
Do you have any other objects that control the book?
I don't think so, no. the only other object in the room is a sound object i think. I can double check tho one sec
oh and theres also an object that activates the dialogue system I have setup but that also has nothing to do with the object
thats all
and the background thingy
Did you by any chance modify the instance of the book in the room editor
Via the instance properties window
not using the properties window, no. the only change I made was I enlarged it a bit bc the sprite itself was very small compared to the size of my room.
Okay
Could you take a screenshot of your book object, everything
Events, its properties, etc
(I know we only have step but I need to see it all in view)
oh I deleted step. should I not have done that?
Well I hate to tell you, but what you’ve told me vs shown me so far seems to indicate that something is in fact, changing the visibility of the book
Because there’s nothing by any means that should be stopping that book from drawing at all
Which means, there is something code related that I cannot see
huh. well I have no clue what it could be i mean i havent refferenced it in any code.
There’s plenty ways you can refer to an object index, even by accident
maybe if we try manually drawing it with a draw event?
i mean i do have a massivley complex dialogue system i just copied the code from a vid that could be it but i doubt it bc the object and sprite did not exist when i made it
Like
with(all) {
visible = false;
}
Or
var index = 0;
index.visible = false;
dont think i have that at all
I don’t have your project so I can’t tell you anything
dont think i did anything like that
This is the same for anyone’s projects
You need to know your own codebase, or have the capacity to search through it
Not everyone can help you there
i mean i can export it and send it for diagnostics but only if we really need to.
Well at this point, I can’t help you much further
ok. so should I send it or no?'
You can dm me a yyz file
File -> Export As -> YYZ
ah shoot
is google drive ok? the file is too big for discord
and i dont have nitro
How big are we talking? 🤨
What’s the size? Mb? Gb?
yeah
If it was like 200mb or something, I would’ve had just told you to use source control at that point and send it to me that way
(You should be using source control anyway)
idk what that is...is that wierd? should I know that?
It’s the best kind of backup system for programmers code
Gamedevs too
It’s also mainly on the cloud, away from your pc
oh i see. Ill research it later
So if your pc goes kapoot, you have it online still
Anyway
Google drive is fine for yyz
sent
I saw haha, cheers
Gimme a bit
ok no wonder @molten rock, your viewport settings are extremely small
???
oh yeah. i mean i used a template so that was default
That white box is your view
Yeah I noticed
ohhhhhhhhhhhhhhhhhh
i though the viewport didnt work without the player in there though. guess i was wrong.
I moved it and rescaled it
Nah your view will always be there, it just follows the player
ok. how do i change it?
You can scale down the object (easier), or change the views directly
via the viewports property
I would normally go on something way more better, but you're not using a custom camera system here
(Via code I mean)
oh yeah i scaled it down. thanks its all good now
No worries
wait how do i set my sprite not to continuesly do the animation? it's a thingy i wanna trigger with a script.
At that point you'll have to code your book and control it from there
How exactly you wish to do it really depends
But an easy thing you can do is just set the image speed of the book to 0, and then change it to 1 when you need to
In the instance
oh thanks
// Create Event
image_speed = 0; // This controls the speed in which the sprite updates, 0 pauses it.
the speed is the fps, right?
Nope
I already told you
Let me just tell you what it is
And then you can go from there, okay?
ok
i mean i know i can do it in code but is there a way to change it in the spr editor?
image_speed corresponds to how frequently it updates. 0 is "no updates", 1 is "normal sprite update rate", 0.5 is half the update rate
All of these are affected in response to your sprites own frame speed as well
yeah thats waht i was doing. I thought said it was wrong though, ig i was wrong. thanks.
Though keep in mind, if you set that to 0, the sprite frame speed itself, then it will never ever update
And you'll have to update the image index manually at that point
ok thanks you have really helped. Have a nice day.
You too! 🙂