How to get camera to follow an as of yet loaded object?

So, I have an Empty in a plain with a script that allows loading of a range of playable characters into that Empty (male / female for example). I tried to parent the Empty to the camera in the hops that the camera would follow the selected player in 1st person, as I can not parent the camera to a yet to be selected/loaded character. Of course, this did not work and it is clear why, the Empty isn’t what is moving around as all that logic is used on the individual characters.

My question; how can I go about setting up some sort of link between the yet to be loaded character and the camera in scene so that the camera follows the selected player?

I feel the answer will be either incredibly simple or incredibly complex… :confused:

Umm maybe you could send a message to the camera after the player is loaded and add a parent actuator to make the camera the child once it gets the message. You can try. Might work. Hope I helped!

yeah, ezio said it well.
Of course there are easier ways with python if you know how
Here’s how the code will probably work:
spawn in character from empty, store in a ref variable
send that to the camera and the camera will decode and parent to whatever spawned

there probably are better ways, so just keep lookin’

You could just create a default character with all the proper physics and change out the animation mesh to the desired character. Check out my set up here for an idea of what I am talking about. This set up uses mouselook, WASD dynamic movement, and first or third person viewing. It has a rigged character with no animations, all you would do is swap out the animation mesh for the one you want to use. Of course each mesh would have to share similar topology.

That is a cool idea, but in my example, the characters are actually cars, each with different characteristics handled by config files that the python references. P.S. the code is not mine - its truly beautiful though! EDIT. actually, since external files handle the characteristics, maybe it would work?

As for the other ideas above, how can i set up so that the character sends a message to the camera on spawn? Wouldn’t I need to have the specific object already loaded to add that sort of messaging logic to it? I hate to ask, but does anyone have a simple example of this? Anytime I’ve used messages, it was in situations such as collisions and referenced objects already in that blend file.

The same principle applies, just change the animation mesh and logic controller. Your camera and placeholder never have to go anywhere. You can use this method for anything.

Trying to get my head around what I did, might have set up this better. The way I have it setup is simple but makes it hard to work with it in this way. I.e. I have A.config which sets variables for A.blend, and B.config for B.blend, where the blends contain only a single vehicle to be loaded.

OK, so each blend is a self contained vehicle with physics, config, etc. Start with the common features they all share, i.e. empty and camera, use that with a generic car template as the starting point. When you want to change cars, load in the blend, swap the mesh with the generic template, swap the config file. Your empty and camera never change, but now you should have the correct mesh and config file.

OK so I thought about CaptainAndrews solution but this solution is causing other problems (like an anti-depressant) as the vehicles/objects are not the same size, etc, etc.

So I tried to go with the previously mentioned solution about having the object broadcast a message to the camera but I am unable to then have the camera which receives the messaged parent to the object as the object is not in the same blend and therefore not in the list to select from. See attached screenshot of what I did to each object in each blend, it will explain better.

Anyone have any other thoughts, fixes, anti-depressants I can have? Many thanks! :slight_smile:

Maybe this helps you: Switcher - cycle through an object list