teleporting from one map(file) to antother and back

Let me explain this a bit, basically I just got done experimenting with #GameLogic.globalDitc[‘xyz’] = xyz

and I found out how useful it can be, the only issue in my situation, is that I need the character to go back to exactly where he was when he first leaves the scene. A good example would be a classical rpg game where you get an encounter, your teleported to another scene where you fight and when you win, your teleported back to the the place from whence you started the encounter. Now, getting the stats such as hp and sorts is not a big deal if I use the global dictionary, but I tried calling GameLogic.globalDict[‘position’] = me.getPosition(), thinking that would work, but without further adue, I came up empty handed. I was wondering if anyone could push me to the right direction to solve this or where I can learn to do such things. Thanks.

What do you mean with empty handed?

GameLogic.globalDict[‘position’] = me.getPosition() would just store the position.

Have you restored the position with me.position = GameLogic.globalDict[‘position’] when you came back from the “fight” scene?

OK, I figured it out, I was just too tired to think. the save script worked, the line you posted me.position = GameLogic.globalDict[‘position’] doesn’t work, cause you have to call a function, but you can’t assign a function… but, you can tell it what to use… and I just fixed it by doing this.

me.setPosition(GameLogic.globalDict[‘position’]

Cause you’re telling the function to call up that variable and use it. This is very exciting to me, first time actually making code to be used in a game. I’ve been studying and stuff so all of this makes complete sense to me, that just makes me feel a whole lot better bout my life in total haha. Thanks for the lil’ thunker, helped me get everything straight.

KX_GameObject.setPosition() is deprecated with 2.49. It is now the instance variable position or localPosition. See http://www.blender.org/documentation/249PythonDoc/GE/GameTypes.KX_GameObject-class.html

But both ways work in 2.49. But setPosition() will not be available in future. I think it is better to tell the new syntax. You are on the right way by working it out by your own that you have multiple choices.

happy blending
Monster

Hmm, so is it used the same way? The thing was I was using me.position = GameLogic.globalDict[‘position’] and it was not working. Give me an expample of it’s usage if you will, thanks.

Edit: OK nevermind I figured it out hehe. Thanks for the help though, I’ll make sure to look through the deprecated list and find alternates for it.

Another hint:
with 2.49 if you use deprecated methods, you get warnings at the console. The warnings contain hints how to replace these methods. There is a menu item to switch the warnings on/off.

yeah, I found that out as well, but the only thing it doesn’t tell me is for .isPositive(): and .isTriggered():

it tells me it’s deprecated but it’s not actually telling me a replacement, just says to use read-only positive/triggered

It seems confusing sometimes. I had to read it twice or more to understand the real meaning of the warnings. It is exactly what it is saying use “KX_GameObject.positive” and “KX_GameObject.triggered”. Both instance variables are read only.

Yep, I found that out by looking at some example coding. I’m also very excited to know you can pull properties from another object in the scene by using GameLogic.getCurrentScene()

Makes programming a bit easier now. haha.

Okay guys here it is teleportation “WITHOUT SCRIPTS”

2 things you need to know.

How to make a collision in the game engine for 3 objects and

How to switch cameras using logic blocks.

Teleportation has been an issue with Blender.
In reality, instancing is just the use of Camera switching between scenes. And fortunately, it can be easily done with the logic blocks.

And unfortunately for all of you 2.4x folks, this tutorial is in Blender 2.5 !

First set up 4 scenes.

Make sure each scene is in “Blender game” mode -which is set in the menu beside the scene selection menu. ( If you don’t do this for EACH SCENE, you will not be able to instance your scenes, nor will you be able to add game physics)

Label each scene as something you can remember because you will be switching back and fourth a lot.

  1. Scene (default)
    2 Scene2 2boy
  2. Scene3 3boy
    4 Scene 4 4boy

Or you can use any names you wish for your 4 scenes.

In each scene have a plane(mesh) and a sphere (mesh) and a camera.
So you will be creating 4 cameras 4 planes and 4 Spheres.

Position the sphere about 4 blender units above the sphere so that when you trigger a collision you can see it clearly.
Be sure to position your camera so that you can clearly see the collision happen from the camera’s point of view when ever you push “P”!

Now IN EACH SCENE-- parent the camera of that scene to the sphere of that scene.
You must do this because you want the camera to sense the collision of the sphere (mesh) and not necessarily of the Camera itself.

Next set your collision for the sphere and the plane in each sphere.

Just go to the physics tab with your sphere selected and set it to rigid body.
Then check the collision bounds box(leave it as the default settings)
Next select your parented camera an set it to rigid body as well in the physics tabs.
Then check its collisions bounds and leave it as the default bounds settings.

Do this for each and every scene.

Then select your plane and set it to static. be sure to check the collision bounds box and leave it as the default setting.

Do this for each and every scene. So you will be doing this 4x for 4 separate scenes.

The result will be the sphere dropping(and bouncing) onto the plane when you press “P” In all 4 scenes…

THE MAGIC of TELEPORTATION aka Instancing:
In scene 1 ( your first scene)
1 Select your camera(only) open 2 sensor blocks name each of them as “COLLISION”

2Open 2 Controller blocks and leave them as “AND”

3 Open 2 Actuator Blocks and set the first one to “CAMERA” then set the OB: to "Camera.001 ( this should be the camera ID of your second scene) Leave everything else in this block alone.
Set the second Actuator block to “Scene” then choose ‘Set Scene’ in the menu.
then type in the “Scene ID” of your second scene. Leave everything else alone.

  1. repeat steps 1-3 for your sphere mesh in this scene.

  2. Go to your second scene. Apply simple collisions to your sphere, plane and camera as you did in your first scene. ( again if you aren’t in “Blender game” this will not be possible)

In scene 2 ( your second scene)
1 Select your camera(only) open 2 sensor blocks name each of them as “COLLISION”

2Open 2 Controller blocks and leave them as “AND”

3 Open 2 Actuator Blocks and set the first one to “CAMERA” then set the OB: to "Camera.002 ( this should be the camera ID of your third scene) Leave everything else in this block alone.
Set the second Actuator block to “Scene” then choose ‘Set Scene’ in the menu.
then type in the “Scene ID” of your third scene. Leave everything else alone.

  1. repeat steps 1-3 for your sphere mesh in this scene.

  2. Go to your third scene. Apply simple collisions to your sphere, plane and camera as you did in your second scene. ( again if you aren’t in “Blender game” this will not be possible)

At this point you should go back to your first scene and push “P” to test it out.

If you teleport to the next scene then you got it right.
Also experiment with moving once you get into the next scene. This is done of course by additional basic logical block x,y,z, assigning to the sphere mesh.

If you want, you can repeat this process forever with more and more scenes. Thus we now have instancing . You can also loop this method by setting the fourth seen to instance back to the first scene (theoretically).

Now I will test this theory out further; and depending on the capacity of a single scene, we will know how far we can actually push the BGE. If it continues to work well, then that means the BGE won’t get cluttered with high res meshes. Thus, we can have better game graphics by strategically and wisely using this instance method, and we don’t need Scripts.

Happy Blending.

I suggest to open a new thread at the game engine resource forum.
Some pictures would be nice as well.