The Blog

About Me


Marius Oberholster Hey! I'm having an incredible learning experience, not only learning how Blender works (yes, still learning), but also about Open-Source and the incredible software available. Stick around!

BGE - Overlay scene

Posted by Marius Oberholster on Friday, November 1, 2013 Under: Quick Blog Tutorial
Hey all!

Coming at ya with another QBT relating to the Blender Game Engine. This time, we're discussing a scriptless solution to the information mismatch we get when we have more than one scene on-screen. So here is something you may have tried and found out it didn't work (please let me know if this is a bug we can report).

In order to use a text object to display information, you use the property actuator to copy an attribute to the, writing space, if you will, of the text object, but, while you can select an object from the first scene, the information does not carry over. You can select it all you want, it just doesn't carry. It's like there's no bridge between scenes, even in this way.

Last night, I was talking to Dener (friend from FB) about possible solutions to this and everything we tried, just did not work... I was online, googling and reading and reading and googling and getting so frustrated that the above mentioned method wasn't working like it should (in my mind) and that I wasn't getting any solid answers online, so here is a way you can bridge a scene divide, without having to script it out! Scripts are great, but I like to push a logic brick solution as far as possible. So, let's get into it!

Let's say, you've done this tutorial and you have everything set-up, except the data transfer from one scene to another. We're not using a life bar, but simply a text object to display the information.

On the object that has the collision, interaction, sensor etc, that requires information changed and sent (for example the character that gets attacked or jumps a little too far), you add a message actuator.
Please add a subject so you can distinguish what goes where and what is being transferred. While I have no idea how to display what is sent without scripting, I have learned last night that every time a message is sent, it creates a pulse. A pulse is like pressing a button once. That means, whenever something collides, it can pulse in another scene.

Using the message sensor, we then use this pulse to calculate our values on the overlay scene (do not set it on true, so it keeps pulsing). I recommend doing your calculations on the character too, so it knows when to respond as well as send the right pulses.

The message sensor only has one field; subject. Again, I don't know for sure how to display the message, but not having a subject, clearly opens the sensor up to pulses it shouldn't make. Never be lazy to name things right early in a project. You'll be very troubled having to look for the problem in a massive project.
Now, simply use the message sensor like an always sensor that "always" (haha) activates at the right time :D.
A simple way to test this, is to have your game play scene reflect the same information that the overlay scene should. If they match in a timely manner, it's successful and it works.

Just to help you out, here is what the receiving text object in the overlay scene, looks like, logically:

(click to enlarge)
What is going on in the image?
> Property Life - Writes the current life status (game property found far left) in the text object: Text - Variable store
> Property property - Takes one life point away (this is tied to the collision message pulse called Life down)
> Property property1 - Displays the words "Game Over" in the place where the life reading was. This message, Dead, is tied to the character's (a cube in this case) life reading, when it's life or consciousness count reaches 0.
Note: It seems that BGE knows to convert an integer into text to be displayed. Also, I still need to name these properties myself.

And that's basically it!

I hope this tutorial has inspired you to go add 7 scenes to your game, hahaha. Just kidding.

Credit:
- Clark Thames for his brilliant online tutorial on overlay scenes
- Dener for trying to help me figure this one out and for teaching me a bunch of other stuff
- The Blender community for having mentioned that messages can bridge scenes.
- JESUS for giving the solution above! What a blessing to receive and to share! YOU rock!!

Thank YOU!!!!!!

In : Quick Blog Tutorial 


Tags: jesus  quick  blog  tutorial  bge  messages  bridging scenes  overlay scene  working well  learn  sending  a  message from  receive 

"For I testify unto every man that heareth the words of the prophecy of this book, If any man shall add unto these things, God shall add unto him the plagues that are written in this book:
And if any man shall take away from the words of the book of this prophecy, God shall take away his part out of the book of life, and out of the holy city, and from the things which are written in this book.
He which testifieth these things saith, Surely I come quickly. Amen. Even so, come, Lord Jesus.
The grace of our Lord Jesus Christ be with you all. Amen."
Revelation 22:18-21

"Add thou not unto his words, lest he reprove thee, and thou be found a liar."
Proverbs 30:6


King James Version, Public Domain

Ultimate Glory

I give glory to, acknowledge and remember God for this website. He enabled me to do all this and this website belongs to Him. Thank You!

 
 

Make a free website with Yola