Help with overlay scene scoring

I’ve been trying to learn the Blender Game Engine by writing a game. I started with Social’s BGE python tutorial and once I thought I understood that, moved on to other things. Unfortunately I’ve encountered a problem for which I am unable to locate a solution. I want to have a score displayed as the player shoots objects and still retain the score from level to level. I found information on adding an overlay scene and have been able to score in level one, but when the scene changes to level two the score disappears. I’ve tried deleting the score scene in each new level, but that didn’t solve the problem. I’m sure the solution is a fairly simple one, and it is just eluding me because I’m not thinking in that direction (that’s why programmers have flat foreheads).
Another problem that I’ve set on a low priority is mouse control. As it plays now, if the player moves in 3D so that s/he is ‘upside down’ the controls are reversed and sometimes at the initiation of a level the mouse jumps and the player is unable to regain control of the ship. I’m using Clark Thames’ unchanged and he’s included a ‘jump’ preventer in it, but I don’t think that’s really the problem.

The .blend can be found here:

Keep in mind that this is less than a work in progress and so is a pretty nasty conglomerate of ‘this works–that doesn’t.’

The problems that you are having are because of the way the overlay scene is set up. An overlay scene only has to be started once. It doesn’t have to be restarted with each new level. The camera in an overlay scene doesn’t move. It is a separate object (it isn’t linked to another scene). It isn’t parented to an object in another scene.

Your counter is set up in the overlay scene. As it should be. Like the camera, it shouldn’t be linked or parented to an object in another scene.

So, in the overlay scene, make both the camera and counter separate objects. Remove the parents. Remove mouselook from the camera.

In your scoreback script, don’t forget to initialize GL.score and you’ll also need some code in your score script to pass the score from level one to level two.

In the levels, you have mouselook on both cameras. Only need it on one. The camera are both parented to the same ship which is what is being rotated with mouselook.

Mouselook moving the wrong way. In the mouselook script up near the top, you see these instructions

# Use either 1 or -1  (Minus one will flip the direction.)
directionLeftRight = 1
directionUpDown = -1

Change directionUpDown from -1 to 1

Thanks for the quick reply. I’ve used the flip direction in and it does work to switch directions. The problem, though, is when the player inverts the ship during game play. I just had a thought. I can try to add a variable that will change that switch when the ‘homeworld’ indicator is pointed in the opposite direction from the ship.
Thanks again for the suggestions. I’ll give them a try and repost.

You’re using the mouselook script a little bit differently than what it was originally written for. Which means that it needs to be changed a little.

Rotate both using the local axis.

# Set the rotation values
leftRight.setDRot( 0.0, 0.0, rotLeftRight, True)   
upDown.setDRot( rotUpDown, 0.0, 0.0, True)

Thanks again. Both of those solutions worked. I was thinking I needed an exact copy of the camera to make the overlay work. I just deleted the camera and added a new one in the right place and it worked. For some reason, I was thinking that the overlay would hold the number for the score, so I need to figure out how to do that too. That shouldn’t be too hard. I think I’ve seen something like that on the forums already.
The local switch was a good pointer as well. I knew it was possible to make rotation local, but it didn’t occur to me to actually change it in the script.

I like this forum. Most of the questions I’ve had about Blender and the BGE have been answered already and I’ve only needed to search for them. I appreciate the willingness of those on this site to help out. Special thanks to cthames, Social, and Blendenzo who have provided the most information that I’ve used.
I’ll post a completed version of this game when I’ve finished with it. Feel free to use anything you like from it just give credit where credit is due. The was made by cthames and the was from Social’s python tutorial. The sounds were made in Audacity and the textures were made in Gimp.

You wrote

For some reason, I was thinking that the overlay would hold the number for the score,

It will if you want it to. Using the code you already have, instead of using the same global variable (GL.score) for both level one and two, use a different one for each level ( GL.score1 and GL.score2 for example). Then in your script scoreback,

own.Text = GL.score
own.Text = GL.score1 + GL.score2

Ah, the light comes on! Ok, that makes sense. Thanks for the help. I think I’m on the downhill side with this game. It’s been an enlightening experience.