Master Camera Problems in BGE

Hello! I’m new here, so I have no idea if I’m doing this right just tell me. :wink:
In blender stack exchange, kind Mr. Monster showed me how to use python to get my cameras in my game to move in sync throughout scenes. My level scene had to have an orthographic camera, but the background to it had to be in perspective from another scene. @Monster told me to use a Master camera with this code:

import bge

scenes = bge.logic.getSceneList()
slaveCameras = [scene.active_camera for scene in scenes]

for scene in scenes:
    masterCamera = scene.cameras.get("Camera.master")
    if masterCamera:
        masterKey = masterCamera.get("master")
        for slaveCamera in slaveCameras: 
            if slaveCamera.get("slave") == masterKey:
                slaveCamera.worldTransform = masterCamera.worldTransform.copy()

I did. It worked perfectly. I then tried to make the master camera a slow parent and then whenever I started the game, my entire computer froze up and I had to wait a super long time or unplug it before it would unfreeze. I tried replicating this problem in a new .blend but it worked fine that time. Then I remembered that in my real game, the physics cube of my character plays an action that scales it by -1 whenever it is turning left that way the shape would be turned around to face the other direction (this is a 2d game, mind you. :slight_smile: My camera is parented with Keep transform, which I think means that it won’t scale when my cube does, but I have also tried it with all the other ways to parent it. When I have my scale actions on but the camera is not a slow parent it works seemingly well, but now when I turn slow parent on, it does weird things, so maybe that’s where the freezing was coming from. I really have no idea what’s going on anymore. Here is the blend file. Ignore the banana, I was seeing if an armature with something parented to it had anything to do with the problem and I don’t think it does.
My Misbehaving Test File
Thanks!

P.S. If I don’t make sense as to what my problem was and how Monster helped me solve it, here’s the link to the stack exchange thingamajig: How to get a camera to copy location of character from a different scene in BGE

I would also add my actual game, but it’s filled with “images as planes” so I don’t know how to upload it with all the files that go with it. If that’s possible, please tell me how. Hehe. :wink:

Just zip or rar it with winrar and then upload that file.

What happens if you manually set the other cameras to slow parent as well?

LOL winrar? 7 zip is better.

make a backup of your project in case. file, external data, pack all into blend.

then use 7zip

Hmmmmmm. . . .
Aha!
My Misbehaving Game
How about that? I am using blender 2.78, I haven’t done UPBGE yet, whatever that is, but I’m thinking about it.
P.S. I’m not very techy sometimes. :stuck_out_tongue:

@Cotaks @Daedalus_MDW . Sorry, I don’t know if you guys get notified when I leave a comment like in stack exchange. :wink:

When I open the game on some of my other computers, the scale actions do not work very well, but that might be because they have even older versions of blender. Please tell me if all his parts discombobulate for you. :smiley:

No idea.

anyway, tested you file, works good but you got some issues.

Check your console output

Summary

Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “TopDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FrontDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FlankDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Blender Game Engine Started
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “TopDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FrontDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FlankDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
warning: scene TreeTopTown.Background already exists, not added!
warning: scene HUD already exists, not added!
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “TopDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FrontDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FlankDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
warning: scene TreeTopTown.Background already exists, not added!
warning: scene HUD already exists, not added!
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “TopDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FrontDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FlankDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
warning: scene TreeTopTown.Background already exists, not added!
warning: scene HUD already exists, not added!
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “TopDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FrontDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
Warning, sensor “Collision.001” has lost a link to a controller (link 1 of 1) from object “FlankDamage”
possible causes are partially appended objects or an error reading the file,logic may be incorrect
warning: scene TreeTopTown.Background already exists, not added!
warning: scene HUD already exists, not added!

Also, i need to hold ‘up arrow’ to jump and if i release it it drops like a brick? bit strange.
But slow parent is on and everything seems to work. I like the style nicely done.

Are you kidding? You put slow parent on the master camera and it worked? Hmmm. Maybe I just need to upgrade to UPBGE or something. Is that what you’re using?

you have slow parent already activated in the blend.

i use bge 2.79 i don’t use forks

@Cotaks oh wait. Try enabling the slow parent for the inactive camera because that is the Master camera even though it does not get used. that’s what makes it all weird for me. Or is that what you did?

No i did not, so tested it again, look at the video:

Oh. Sorry, bro. There is one more camera that is parented to the character cube called “donkey kong.” That’s the one that needs the slow parent. There is a whole string of things parented to that cube, however, so you have to pan sideways to see it. I’m trying to have slow parent set to about 30 frames on that camera, so there would be a noticeable difference.

Also. . . about that cube at the end. That is a test barrel cannon. I have it set so that when you collide with that cube, the “donkey kong” cube parents itself to an empty and the empty plays an action that “shoots” the character to whatever platform I direct it to. I tried it all out in a test file and it worked fine, but not in my game and I can’t figure out for the life of me why. Here is the test file if you’re interested in giving it a look.

Barrel Cannon Test File
(Arrow keys to move, spacebar to shoot.)

Also, in my game, if you push and hold r (for now at least) you can run. :slight_smile:

Ok, the problem you have is the script you are running from monster, it’s updating it’s transforms (position/orientation/scale) this causes slow parent to screw things up. This line causes it: slaveCamera.worldTransform = masterCamera.worldTransform

if this is the case, copy the transforms to an empty, then slow parent the camera to the empty that transforms.

Indeed, had no time left yesterday, needed to sleep, eyes got to tired lol.

@DaDudeII here is a fixed .blend

what did i do?

  • removed the second camera in the main scene (why 2?)
  • added a master_cam_hook (empty)
  • vertex parented it to DK (just like you had with the master.camera)
  • changed the master cam parent to the empty, instead of DK
  • put slow parent on, on the master camera

That’s it.

https://ufile.io/q8h7r

You are a gentleman and a scholar, sir Cotaks. It works perfectly. :slight_smile: That totally make sense too. I need to start learning some coding. Thanks a lot!
P.S. Sleep is healthy, no worries. :smiley:

Thanks, Daedalus_MDW!

No problem, i’m glad that the result is what you needed, even if i removed a camera.

But this had nothing to do with coding to be honest, both code and slow parent works independently. This case was figuring out how you had set it up, and why it would not work. Once i knew that the transforms where the problem i directly knew the fix for it, so did Deadalus.

But indeed, it’s good to learn python, you gonna need it sooner or later.

1 Like