0
$\begingroup$

Is it possible to send a message from one scene to another? According to the manual page, it should be possible if the object field is left blank. I have a collision sensor which sends a message when player hits a flag at the end of a level. I want to have another scene which charts my progress through the levels and adds a 'level complete' icon to the display. However the message sensor I am using in the progress scene is not receiving anything. I have tried adding the progress scene as a background scene to the level scene and I can see the property I am using to check does change but is reset as soon as I enter the progress scene and the message is not received. I have also tried using a blank overlay scene in both scenes to track the message on an empty but no joy. Hope that makes sense and thanks in advance for any help with this!

$\endgroup$
1
$\begingroup$

I've done some tests and you can not send a message to a scene that did not loaded.

In the example 1 the scene1 send a message when mouseOver the scene2 recive the message and add 1 to count, i use a script to print the value.

Scene 1 logic:

enter image description here

Scene 2 logic:

from bge import logic

obj = logic.getCurrentScene().objects['Suzanne']
print(obj['count'])

enter image description here

Behaviour when:

scene2 IS NOT an overlay nor background

enter image description here

scene2 IS overlay or background

enter image description here

In the example 2 i dont use any message. I store the value in an attribute of bge.logic module.

Scene 1 logic:

from bge import logic

if not hasattr(logic, 'count'):
    logic.count = 0
else:
    logic.count += 1

enter image description here

Scene 2 logic:

from bge import logic

if hasattr(logic, 'count'):
    print(logic.count)

enter image description here

Behaviour when:

scene2 IS NOT an overlay nor background

enter image description here

$\endgroup$
  • $\begingroup$ Thanks for the information. I thought the messages survive the scene switch (maybe they did in the past). $\endgroup$ – Monster Dec 11 '17 at 9:14
  • $\begingroup$ I just tested with 2.74 and it worked with message and set scene. ... the same file works with 2.79 too. $\endgroup$ – Monster Dec 11 '17 at 9:22
  • $\begingroup$ Yeah with set scene it work, but i understood from the question that the op want to send from scene1 a message to scene2 to add something in scene3 while you still in scene1. Not understood that will send a message from scene1 to scene2 and then load scene2. Maybe my bad english. $\endgroup$ – Strapicarus Dec 11 '17 at 23:00
  • $\begingroup$ You are right. Unfortunately I do not fully understand the description of the question. The title of the question seams not to describe the real business. $\endgroup$ – Monster Dec 12 '17 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.