#Issue with object layering/rendering

1 messages · Page 1 of 1 (latest)

errant crystalBOT
hollow berry
#

Okay, going to need some context. When you say invisible, do you mean just in the room editor or in-game?

molten rock
#

both

hollow berry
#

Okay, what is the current sprite of the object?

molten rock
#

an animated book sprite.

hollow berry
#

Could you show me this animated book sprite?

#

A screenshot would do

molten rock
#

sure one sec

hollow berry
#

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

molten rock
#

i can send a screenshot one sec

#

the highlighted obj is the book obj which should be visible but isn't.

hollow berry
#

Right so

#

It's behind the background layer

#

That's why

molten rock
#

how do i fix that?

#

sorry im new lol

hollow berry
#

Move the background layer below the instance layer

molten rock
#

ok thanks lemme try

hollow berry
#

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

molten rock
#

ok thanks

#

hmmmmm ok it appears in the room editor now but still not in game...

hollow berry
#

Do you have a draw event?

#

Is it drawing your book sprite

#

Is the object visible property unchecked?

molten rock
#

no draw event no events at all

#

yes visible is enabled i checked all that

hollow berry
#

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))

molten rock
#

I mean its listed in the instances layer

hollow berry
#

Not

#

The room editor

#

You need to be checking in-game too my guy

molten rock
#

how do i do that again?

hollow berry
#

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.

molten rock
#

oh so in like create evnt or a script or smthing?

hollow berry
#

Preferably step

molten rock
#

i can do that

#

one sec

hollow berry
#

If that instance goes poof at any point, you'd be able to trace it down from there

molten rock
#

which one do i use tho? all?

#

instance exists or show debug message?

hollow berry
#

That depends

#

Which object are you putting it in?

molten rock
#

can i just put it in the book object itself, or no?

hollow berry
#

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

molten rock
#

is that all the code i need to put in the object?

#

show_debug_message(a_counter)

hollow berry
#

I'm merely giving examples, not definite code

molten rock
#

putting that in the book obj

#

ok

#

well im still new to gml. will i need to add onto the code or no?

hollow berry
#

show_debug_message() is the key one, but what you put inside of a_counter should be a value that counts, or changes

molten rock
#

what i mean is show_debug_message(a_counter) will it be good on its own or do i nmeed to add something?

hollow berry
#

Lemme give you a hint ||a_counter isn't a built in variable of any kind||

molten rock
#

ohhhhhh ok

#

so that itself would not work?

hollow berry
#

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)

molten rock
#

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.

hollow berry
#

Right, give it a run and see what happens then

molten rock
#

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?

hollow berry
#

Taking a step back

molten rock
#

?

hollow berry
#

What was the error

molten rock
#

I didn't try it yet. should i try it or no?

hollow berry
#

Not with your current code no

hollow berry
#

Give me the error

molten rock
#

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?

hollow berry
#

You didn't do what I said

#

But yes, the code "works"

molten rock
#

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

hollow berry
#

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

molten rock
#

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.

hollow berry
#

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

molten rock
#

anything that would apply to most languages i know

hollow berry
#

Now your code also works, but not what I was really aiming for

hollow berry
#

There was a reason why it's called a_counter

molten rock
#

yeah i know you wanted me to make a counting thing but idk how

hollow berry
#

Okay, how do you define an instance variable?

molten rock
#

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

hollow berry
#

So there's two ways you can define variables for an instance

  1. Variable Definitions (via Object Editor)
  2. 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

molten rock
#

ohhhhhhh yeahhh that ok. by instances I thought you ment the specific instances of objects that are in the rooms.

hollow berry
#

No lol

molten rock
#

i can do that

#

i mean i know what u mean now

hollow berry
#

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

molten rock
#

ok. so what do i do then?

#

do i still do the counting thing or no?

#

i know how now

hollow berry
#

You don’t really need to anymore

molten rock
#

ok

hollow berry
#

Though I’ll note this as well

molten rock
#

so how do i make it appear?

hollow berry
#

For future reference

molten rock
#

ok

hollow berry
# molten rock

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

hollow berry
#

And we have no draw events

molten rock
#

yeah

hollow berry
#

And we already moved the background layer below the instances layer, so we know it’s not due to the background covering it

molten rock
#

yeah

#

what else could it be?

hollow berry
#

So, there’s only two big culprits

  1. The sprite set isn’t what it’s supposed to be set
  2. It matches the background colour
molten rock
#

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.

hollow berry
#

Well the book has no code

#

And it’s set to the sprite in the object editor

#

But

molten rock
#

yes

hollow berry
#

Do you have any other objects that control the book?

molten rock
#

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

hollow berry
#

Well then easiest way to confirm anything is

#

Just change the background colour

molten rock
#

ok one sec

#

nope still doesn't show up

hollow berry
#

Did you by any chance modify the instance of the book in the room editor

#

Via the instance properties window

molten rock
#

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.

hollow berry
#

Okay

#

Could you take a screenshot of your book object, everything

#

Events, its properties, etc

molten rock
#

ok

#

one sec

hollow berry
#

(I know we only have step but I need to see it all in view)

molten rock
#

oh I deleted step. should I not have done that?

hollow berry
#

That’s fine

#

We don’t really need to worry about step right now haha

molten rock
#

there

#

theres nothing to see in physics parents or variables havent touched those

hollow berry
#

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

molten rock
#

huh. well I have no clue what it could be i mean i havent refferenced it in any code.

hollow berry
#

There’s plenty ways you can refer to an object index, even by accident

molten rock
#

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

hollow berry
#

Like

with(all) {
    visible = false;
}

Or

var index = 0;
index.visible = false;
molten rock
#

dont think i have that at all

hollow berry
#

I’m not saying you have that exact code

#

I’m providing examples

molten rock
#

I would check but theres just too much code to go through lol.

#

i see

hollow berry
#

I don’t have your project so I can’t tell you anything

molten rock
#

dont think i did anything like that

hollow berry
#

You need to know your own codebase, or have the capacity to search through it

#

Not everyone can help you there

molten rock
hollow berry
#

Well at this point, I can’t help you much further

molten rock
#

ok. so should I send it or no?'

hollow berry
#

You can dm me a yyz file

molten rock
#

ok

#

one sec

hollow berry
#

File -> Export As -> YYZ

molten rock
#

ah shoot

#

is google drive ok? the file is too big for discord

#

and i dont have nitro

hollow berry
#

How big are we talking? 🤨

molten rock
#

idk just too big for discord

#

without nitro, anyways

hollow berry
#

What’s the size? Mb? Gb?

molten rock
#

lemme check

#

48,880 KB

hollow berry
#

So 48mb

#

Okay not too bad

molten rock
#

yeah

hollow berry
#

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)

molten rock
#

idk what that is...is that wierd? should I know that?

hollow berry
#

It’s the best kind of backup system for programmers code

#

Gamedevs too

#

It’s also mainly on the cloud, away from your pc

molten rock
#

oh i see. Ill research it later

hollow berry
#

So if your pc goes kapoot, you have it online still

#

Anyway

#

Google drive is fine for yyz

molten rock
#

sent

hollow berry
#

I saw haha, cheers

#

Gimme a bit

#

ok no wonder @molten rock, your viewport settings are extremely small

molten rock
#

???

hollow berry
#

This is your room size

#

This is your view size

molten rock
#

oh yeah. i mean i used a template so that was default

hollow berry
#

That white box is your view

hollow berry
molten rock
#

ohhhhhhhhhhhhhhhhhh

#

i though the viewport didnt work without the player in there though. guess i was wrong.

hollow berry
#

I moved it and rescaled it

molten rock
#

how do i change it?

#

oik

hollow berry
molten rock
#

ok. how do i change it?

hollow berry
#

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)

molten rock
#

oh yeah i scaled it down. thanks its all good now

hollow berry
#

No worries

molten rock
#

wait how do i set my sprite not to continuesly do the animation? it's a thingy i wanna trigger with a script.

hollow berry
#

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

molten rock
#

oh thanks

hollow berry
#
// Create Event
image_speed = 0; // This controls the speed in which the sprite updates, 0 pauses it.
molten rock
#

the speed is the fps, right?

hollow berry
#

Nope

molten rock
#

oh?

#

where do i change it then?

hollow berry
#

I already told you

#

Let me just tell you what it is

#

And then you can go from there, okay?

molten rock
#

ok

#

i mean i know i can do it in code but is there a way to change it in the spr editor?

hollow berry
#

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

molten rock
#

yeah thats waht i was doing. I thought said it was wrong though, ig i was wrong. thanks.

hollow berry
#

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

molten rock
#

ok thanks you have really helped. Have a nice day.

hollow berry
#

You too! 🙂