# how to interact between diferent scenes in BGE

I have a main scene, where i have my character, rooms... Then I have a scene for healthbar, inventory and all that stuff. And I don't know how to interact between those two scenes. For example: When some sensor is triggered in the main scene, how do I link that with the GUI scene to show some information text or something else?

I know this is probably a very easy question and I should know things like that, but I'm not very experienced with blender game engine, and also I couldn't find zhe answer on the internet.

Thank you for your answers.

• So, essentially you're trying to put a scene with your HUD onto your scene with gameplay? – Scalia Jun 17 '15 at 16:42
• It's not an easy question. Nobody knows how to. Trust me, you can't even make it alternate between layers (although you can store an object in another layer, if you want to clone an object projectile.) – Nefer007 Jun 17 '15 at 17:03
• @Nefer007 I wouldn't go so far as to say that... I was just clarifying as to what he was asking – Scalia Jun 17 '15 at 17:13
• like, add overlay scene?, or, have an event in the main scene trigger something in the HUD? – X-27 is done with the network Jun 17 '15 at 17:33
• yes. like if you would to pick up health and healthbar would increse. – Roki Podpecan Jun 17 '15 at 17:39

## 1 Answer

In the BGE, some methods can be used to interact whileas others can't. My personal favorite way to interact between scenes is by using messages. I have provided steps and an example on how to create what you are asking for. Considering that I have this ("When some sensor is triggered in the main scene, how do I link that with the GUI scene to show some information text or something else?") as my information to work with, I was not sure of what exactly you wanted.

## Steps

(Now knowing exactly what you want, I am not sure if this is your exact situation)

1) With your camera, have an always sensor and a scene actuator to display your HUD:

2) In your hud, select your object that need to be visible and invisible when triggered, and create the following logic:

(This says that when the prop "Show" is true, the object is visible. The object is invisible when the prop is false. When a message "Show" is recieved, it will make the prop True. When a message "DontShow" is recieved, it will make the prop False.)

3) To send the message "Show", select your trigger object and add your logic but make sure the actuator send the message:

4) To make the object that gets triggered invisible, we need an object that sens a message "DontShow":

## Product

I am sorry if I was difficult to understand in any of this, and I don't know if I was, so I've created an example .blend which can be found here. For the .blend file, when you collide with the pink object, a green sphere appears in the HUD. When you press Spacebar, it disappears. Hope this helped!

• I've read the comments, and it seems that you want to add health in the HUD. You can send a message saying "Add", and the object that receives it adds health points to the property for your health once received. – blackhole Jun 18 '15 at 5:36
• Thanks a lot. I also checked the blender manual (blender.org/manual/game_engine/logic/actuators/message.html) and there it says that the alternative to the message actuator would be bge.logic.globalDict, which i know is used for saving game progress, but I don't know how it could be used for comunicating across scenes. – Roki Podpecan Jun 18 '15 at 16:39
• I was looking on YouTube for a tutorial about editing text objects in bge, and I foud this video: youtube.com/watch?v=s55R9mIPE1k So that's how you comunicate across scenes using python controller. – Roki Podpecan Jun 18 '15 at 18:17