Bambi! Remember this Name!!!

Actually no, that’s not my name and I don’t care if you remember me or not (I’d rather you remember my work). I’d like to start my first post by saying that I’ve been blending for a year and am now being paid to blend by the New Zealand (home of ‘The Lord of the Rings’) government. I am a physics/chemistry teacher and co director of an educational IT company called EI (Educational Interactive). I also have a strong interest in AR (augmented reality). The blender community impresses me and it has been a pleasure to watch it progress over the last year.

I have a question:

I have been trying to set a scene using python by calling from a saved file which contains:
GameLogic.scene = Base

I am trying to set the scene actuator by:
act.setScene(str(GameLogic.scene))
GameLogic.addActiveActuator(act,1)
etc

I’ve used print(GameLogic.scene) to make sure that the correct info is being retrieved from the save file and it works fine.

When I run the load command in the game it changes to the scene ‘already’ in the set scene actuator but not the scene in the saved file. I can think of ways to get around this problem but they’re tedious.

I’ve used a similar setup to a game called MonkeyIsland. I understand the associated python in this game, but does the scene loading actually work? I suspect it doesn’t. Has anyone been able to load a scene from a saved file? Any advice would be appreciated

  • Cheers

I hope you don’t mean models, textures, and sounds

from what I can tell, pretty much all you can do is use an add object actuator and an object (or more than one) to place things in your world, but they would need to be in your scene on an invisible layer

are you running that file you load as a python script?
if so, why isn’t Base in quotes?
is Base the EXACT name of the scene you want to go to? (does it exist)

I am still a bit confused.

:smiley:
I didn’t know that bambie sucks!..blood!!!
HAHA
Kiding man. Go on with your work!
Dracula suport.

Funny topic, but in the future be sure to put your question in the topic :slight_smile:

The setScene function doesn’t seem to work, your best bet is to name the setscene actuator the name of the scene it will set, link up all of the set scene actuators to the python, and just call GameLogic.addActiveActuator(GameLogic.getActuator(GameLogic.scene),1)

I do understand your problem I think.
Are you using blender 2.25?
Using the setscene actuator’s “setscene()” method has no effect. This may be fixed in certain builds of the game engine, I don’t know the details yet. As another of my posts suggests the bugs is 2.25 probably arn’t a big concern of those working to update the engine as they have so many other features to work on.

I use multiple scene actuators and use a variable to select one
var=""
act=controller.getActuator(var)

You understand?

(yeah I see mine says same as saluk now…)

Thanks for the replies. So the setScene command doesn’t work. I’ll try your idea Saluk (and bookeater) of adding the appropriate set scene actuators which can then be selectively triggered by info in the save file (this will be tedious :frowning: ).

Oh, and Dracula sorry about the dig - but you did set yourself up didn’t you, or are you actually serious? I think that I’d prefer that you were serious and that you actually did have a significant contribution to make - if so I look forward to seing it. (See the pressure you’ve put yourself under? :smiley: )

setScene() isn’t the onle command that’s broken for logic bricks. For example, setProperty() doesn’t work on collision, ray, touch, near, or radar sensors. I’m not sure how long those functions have been broken, but I think it’s been since version 2.20 when Blender switched from enji to the ketsji engine.

setCamera() - I had to make 9 camera actuators…
Note however that you can have them all on one object linked to different objects in different scenes

Bookeater wrote - setCamera() - I had to make 9 camera actuators…
Note however that you can have them all on one object linked to different objects in different scenes

Could you explain this further, I thought that setting a new camera only worked within a scene not across scenes. And what do you mean by ‘link’ are you talking about logic bricks or object data?

Could you explain this further, I thought that setting a new camera only worked within a scene not across scenes. And what do you mean by ‘link’ are you talking about logic bricks or object data?

Okay you have a character in your game right? and he exists in every scene right? He is linked to every scene. If not try ctrl-L and experiment with that.

When talking about cameras I meant that every scene has the same 9 cameras, they are linked to every scene. With scene actuators this won’t matter anyway.

      I have a  question, is there a way to simply set the maximum fps? my fps go up and down all the time and it changes the way the game works. A grenade at 60 fps explodes sooner than one at 22fps, and since there's some kind of compensation going on it hits the thrower! (this is an example I know I can just use a timer but there are other places in which that is not desireable) I think exes don't compensate (I don't know the word for it) so there may not be as much of a problem there but still.

setScene() works fine here. Note that the set scene actuator must have a valid scene in the "SCE: " box. If you don’t, you get “ERROR: GameObject OBCube has a SceneActuator sceney (SetScene) without scene” and the scene actuator will be completely ignored by the game engine.

Note I’m testing in T2

Alien wrote - setScene() works fine here.

Are you sure? Have you got your python script to actually set the ‘set scene actuator’ or is blender simply using the scene that is already in the actuator (and yes I am aware that you need a real scene name in their already or else you get error messages etc). I think that you may be just getting your script to add the set scene actuator that you already have rather than set it (but I could be wrong) If you truly have got it working you could prove it by putting a scene in the actuator (like normal) and then have your script set it to another completely different scene and then use the addActiveActuator(___,1) to execute it.

I’ve tried this with no joy. If you really are sure of your claim could you give us an example of your srcipt code and your logic brick setup? (actually I probably don’t need the logic brick setup)

If not try ctrl-L and experiment with that

Bookeater - …is there a way to simply set the maximum fps?

Yes, there is always a max for your fps as defined in your vsync settings. I think that your real question is “is there a way to keep the fps constant?” in which case the answer is no (I think). The fps is dependent upon how much your video card is processing, and since this varies so too will your fps.

my fps go up and down all the time and it changes the way the game works. A grenade at 60 fps explodes sooner than one at 22fps, and since there’s some kind of compensation going on it hits the thrower! (this is an example I know I can just use a timer…

Is your grenade’s (and other such examples) motion defined by a motion actuator (and gravity of course)? If so then the motion will change with your frame rate. Using ipos to define an object’s motion will ensure that it’s motion is independent of fps (at least that’s my experience).

Woops, that last post started with a suggestion from Bookeater about using linked players (cntrl L) and I forgot to comment. Yes I’ve tried this but you lose a lot of flexiblity when using linked characters (eg changing character pos or ori in one scene causes them all to change)

Question: If the variables on one linked player change during game play then do the variables on the all the other linked players also change? Anotherwords if I travelled from one scene to another would the new players variables have the same values as the old (I think I already know the answer to this -NO).

What I meant is something like this:


import Blender
from math import *

co = GameLogic.getCurrentController()
# Get the set scene actuator...
act = co.getActuator("sceney")
# changer is the collision object that is used to detect when to change scenes
changer = co.getOwner()
# "sensor" is the name of the collision sensor that triggers us.
# player is the player object
player = co.getSensor("sensor").getHitObject()

cpos = changer.getPosition()
ppos = player.getPosition()
porn = player.getOrientation()

# "2" is the name of the scene we are changing to...
newscene = Blender.Scene.Get("2")
newplayer = None
spawn = None
for obj in newscene.getChildren():
	# "Player.2" is the name of the player in the new scene...
	if (obj.name == "Player.2"):
		newplayer = obj
	# "PlayerSpawn" is an empty that the player will be spawned near.
	if (obj.name == "PlayerSpawn"):
		spawn = obj

spos = spawn.loc
newplayer.loc[0] = spos[0] + ppos[0] - cpos[0]
newplayer.loc[1] = spos[1] + ppos[1] - cpos[1]
newplayer.loc[2] = spos[2] + ppos[2] - cpos[2]

newmat = newplayer.getMatrix()
newmat[0][0] = porn[0][0]
newmat[0][1] = porn[0][1]
newmat[0][2] = porn[0][2]

newmat[1][0] = porn[1][0]
newmat[1][1] = porn[1][1]
newmat[1][2] = porn[1][2]

newmat[2][0] = porn[2][0]
newmat[2][1] = porn[2][1]
newmat[2][2] = porn[2][2]

#newplayer.setMatrix(newmat)

eu = [
	atan2(porn[0][1], porn[0][0]),
	atan2(porn[1][2], porn[2][2]),
	asin(-porn[0][2])
	]

newplayer.setEuler(eu)

# Change the scene...
GameLogic.addActiveActuator(act, 1)

Note that setMatrix doesn’t seem to be in the 2.25 api, and I’m not sure how to get something that makes setEuler do the right thing.

That code gets linked to a python controller activated by a collision sensor and linked to the set scene actuator.

Question one: what is T2?

Question two:

act = co.getActuator(“sceney”)

Here you got the sceney actuator (what was already in the set scene field, I’m picking that it was scene “2”?)

GameLogic.addActiveActuator(act, 1)

This is your last line, here you used the boolean operative (1 = true) to activate the actuator.

I couldn’t see where you assigned a new scene to the ‘act’ variable (at no point did you use the setScene() function). Therefore I’m assuming that your script simply uses the “2” scene that was originally in your “sceney” set scene actuator. I like your script but it is hard coded. What happens if you want to change to scene “3” or “4” etc. Would you use a separate set scene actuator for each, and then ‘get’ them in your script, and then use an ‘if’ test (based on which object your player collided with) and then activate the correct scene actuator? If so then you’ve got the same problem as I do, I can’t set the scene to whatever scene I choose from within my scripts (using setScene(whatever). I must ‘get’ preexiting set scene actuators - this is anoying if you want to make very large immersive games which I do. (I may end up with hundres of scenes in my game - thats a lot of logic bricks, not that you’d need a set scene actuator for every scene on every player or whatever object you were using)

If I get the time I’ll post some of my scripts tomorrow - there must be a way to sort this out (then again, maybe you already have and I just havn’t understood - I’m going to pull your script apart and have a good look inside :D).

Thanks for your post.

He didnt set the scene actuator,
alien-xmp thinks we simply mean activating the setscene actuator but we are talking about
getActuator(‘setscene’).setScene(‘scene’)
A ‘method’ by python standards.

IPOS arn’t any different (and dloc doesn’t work) but a timer does. Suprisingly there is little difference between 60 and 20 fps anyway except the motion is 3 times ‘smoother’
and AIs are 3 times stupider and so on

really what’s the copensation I mentioned called?

Thanks

Bookeatr wrote - He didnt set the scene actuator,
alien-xmp thinks we simply mean activating the setscene actuator but we are talking about
getActuator(‘setscene’).setScene(‘scene’)

True. Hey I’ve come up with a fix for the accursed setScene() problem. We could simply use messages (which can be set :wink: ).

  1. When the player hits an object a script (lets call it ‘hitobject’) is activated that uses getHitObject().scene (where scene is a property on the hit object (sorry you already new that huh)

  2. the hit object (door, sensor plane etc) has a string property called scene, the strings value can oviously be different for different objects.

  3. The script will get the value of the scene string and use it to set a mesage actuator which is then made active.

  4. The message (based on what was in the hit objects scene string) will be sensed by a sensor on an empty.

  5. The empty has a set scene actuator for every scene in the game and a separate sensor/controller for each set scene actuator.

  6. Each sensor on the empty ‘hears’ its own specific message and are triggered by the message from the ‘hitobject’ script.

  7. In this way we could selectively choose what set scene actuator to activate by using the collision. Collisions with different objects will result in different mesages being sent and different set scene actutors activated. Most importantly the script would be very small with no ‘if’ tests to choose between scene actuators (ie flexible - no hard coding). It could also be used in conjunction with your save/load system. The empty with all the set scene actuators could be simply linked to each scene.

I’ll try this approach today and post my script and logic brick system. (thats if you want?)

Bookeater wrote - IPOS arn’t any different (and dloc doesn’t work) but a timer does.

Yeah timers run off the cpu clock. I only mentioned IPO’s because I’ve run tests with objects whose motion is IPO controlled with objects whose motion is controlled by the motion actuator.

Try it. Write a dynamic runtime (keep settings as 640*480) then start your exe. I had a fan (controlled by an x rotation value in the motion actuator) and a swinging light (IPO controlled), as I changed the size of the window the game ran in (and therefore fps), the fan changed speed but the light kept swinging with the same period :). I’ll double check this to make sure.

Bookeater - really what’s the copensation I mentioned called?

Yes there is a term for this - but I can’t remember (sorry)

Force and LinV in motion actuators are both framerate-independent, so are IPOs and actions. The only two ways you might get different speeds at different framerates are with DLoc, (moves certain distance each frame,) or using force for 1 frame only, (like for jumping.)

I have made a file demonstrating this.
http://wiseman303.dyndns.org/b3d/files/frameratetest.blend
There are two scenes, one demonstrating adding force for one frame only, the other demonstrating constant force. Both scenes also have an object using LinV to compare the force object with.
Use leftcontrol to toggle slow or fast framerate in both scenes. In the “Jump” scene, use space to jump.