Game object enable (SOLVED)

I don’t understand the documentation about the messages “enable” / “disable” sent to a game object.

Suppose go1 is a game object having go2 has child, suppose moreover that go1 has the sprite component sprite1 and go2 has the sprite component sprite2:

go1
|
— go2
| |
| — sprite2
|
— sprite1

What does the line

msg.post(“go1”, “enable”)

to sprite1 and sprite2?

The disable message will only affect the components on the game object it was sent to. Any object that happens to be a child is not affected. In your example only sprite1 would get disabled.

Thank you!

But in what way is sprite1 affected? It’s enable status is overwritten by msg.post(“go1”, “enable”)? or the enable of sprite1 is the AND of that of go1 and of that of sprite1? In other words, suppose that sprite1 is disabled and I have the line

msg.post(“go1”, “enable”)

Is now sprite1 enabled or disabled?

I am sorry for the many edits… It seems I am not able to explain clearly my question… my apologize…

A game object has no enable or disable state. It is only the components. By sending the message to the game object you target all of the components on the game object (all of the components will receive the message):

msg.post("go1", "disable") -- disable all components of go1.

You can also disable a specific component of a game object by targeting it directly:

msg.post("go1#sprite1", "disable") -- disable only the sprite1 component of go1

1 Like

Thanks, now it is clear!