camera doesn't follow the target object

Hi everybody :smiley:
I am trying to make the camera following an object (Cube) wich is shooted by an emitter (Empty) like a particule. The shooted object is not on the same layer with the other objects. And its layer is not enable.

It seems that the camera doesn’t detect the object that it should target when it’s shooted from the emitter.
I have used the actuator “camera” to target the object. To shoot press “Q”

I join my blend test file where you can maybe better understand what I am explaining.

test.blend (492 KB)

Is there any possibility to make the camera following the shooted object ?

THANKS for your tips !

keypress (shoot)-----python

import bge
if sens.positive:

and in camera
property Target=string=Empty

if Target!="Empty":
    if own['Target'].inavlid==False:

Hi BluePrintRandom,
thanks for the quick answer,great!
I’ve tried to insert the code as scripts in the python logicbricks, but it doesn’t work. I think I haven’t paste them at the right place.
Could you paste your scripts in the test blend file I’ve attached in my first post ? And upload its update on this Thread.
That would be very cool !

Ok, I made a example

note, I renamed the camera bob,

Camera is a object “Bob” is parented to


Demo.blend (454 KB)

Hi BluePrintRandom, thank you very much for the file !
But I think maybe I didn’t explain very clearly my problem. Actualy I would like that camera also go with the cube and not only follow it like watching at it.
There this actuator logic brick “Camera” that is actualy doing this perfectly when the followed object is allready present in the scene; but that actuator doesn’t work for some reasons when the object is been added.
So what I am trying to do is this:

I hope it a bit more clear :smiley:


that is what I have done, however you just need to move things around a bit,

object 1 - add Object 2 -> moving at X speed set property in camera Parent, Target

Camera Parent -> TrackToTarget

the only thing I think it may be missing is,

Bullet hit/disappear return to gun?

Adding a object from a hidden layer, means it has a unique key,

this is why I send the key to the camera Parent -> Camera[‘Target’]=added object

we could do, add bullet, parent camera to bullet,

then return X seconds after impact, is that what you want?

Hi PrintBlueRandom,
I’ve triyed to understand the scripts of your demo (actualy I am a total noob for scrpting) and it makes me understand that the camera stay focus on the position of the added object as it is placed in the inactive layer, because the camera doesn’t make the difference between the original object (on inactive layer) and the added object on the active layer.
And there is no possibilities to differenciate it in the logic brick actuator “Camera” by adding or checking a Property.

So I’ve tryied to make a script wich actualy doesn’t work, but maybe it can help to understand my intention.
DetectAddedAndFollow.blend (512 KB)

The Camera is linked to this script, that make it looking permanently for the added object (the object should be added only one time, so that we don’t have to differenciate each added object). And when the added object is becoming true through its bollean property named “Target”, it become a target for the Camera which have to follow it, like the actuator logic brick “Carema” would do in this case.

Could that work this way ?

ok so you want that camera follows the bullet ?

you can do it that way-

1 when you press shoot key it adds a group object which contains a bullet and a camera parented to it(it is in hidden layer)
2 bullet camera will have an always sensor connected to scene actulator which set camera to bullet camera
3 bullet has a collision sensor (which detects if bullet collides something) which ends the bullet and send message to camera and set the original camera
4 when bullet camera recieve message it destroys itself

maybe this will work

bullet.blend (479 KB)

this may help you. press spacebar to shoot bullets and camera will follow bullet and when bullet destroys camera is back to original . oh and no python is needed at all

How to: deal with TrackTo and added Objects

Thank you KASHI$H and Monster, great !!
Exactly what I wanted to do !

your welcome. i’ve seen this effect in max payne:D

import bge
from mathutils import Vector

Offset = Vector([0,-1    ,0])

would will need a separate script in the bullet to put the camera back, and end the bullet

Thank you BluePrintRandom ! :slight_smile:
I’ve integrated the script in my blend file, but the camera still doesn’t catch the added object properly. Actualy the camera is still following the object from the inactive layer, when I press SPACE. We can see that it’s trying to catch the added object. But it doesn’t come close to the added Object.
Don’t know why. Did I forget something maybe ? Does it depend of my blender version (I work with blender 2.67) ?

I added 2 lines (from your Demo blend file) to your code (the console showed me that is was missing):

cont = bge.logic.getCurrentController()
own = cont.owner

You can see that in my blend file
Demo_DetectAddedAndFollow.blend (523 KB)

For the moment I don’t need to put the camera back and the bullet.

THANKS for your feedback