Camera Actuator: change cameras target object???

Hello, I looking to make my camera actuator change what object it wants to track.

The Camera object value is set to Cube.002. But I want it to be what ever happens to be more near it.

lets say all enemies have a property called “look at me”

which ever object with “look at me” is closer to the camera, that object would be the new ‘camera object’ (the camera’s target)

How can this be achieved?

check the S2Afor S2A.hitObjectToObject or S2A.closestHitObjectToObject.

This can be used for TrackTo actuators as well (see docs)

Thank you Monster, but I still have some questions
Tracking to (enable disable).blend (407 KB)

I’ve read through the links you gave me, I think I understand the concept of how this works.

However, I’m not sure how to apply it to my set up. I’ve used a script that your blend file offered “S2A.blend” But then the my set-up stopped working. (I know, I did something wrong.)

I set it back to my original set-up so you can see how it currently functions.

And I put a text in there explaining the current controls, and what I’m trying to achieve.

Thanks again.

^^^Oh yeah, I posted the Blend file ^^^

it’s encoded in text for some reason, but it still downloads.

I’m not 100% sure what exactly you want. But here is what I did:

  • you can deactivate the False Pulse at all message sensors. Diactivatinf Property actuators all the time is waste of processing time even if it is not much ;).
  • the python file should be named Otherwise the python controllers can’t find it.

I added following logic to your focal point object:
a) A near sensor: property “track” distance 10 reset 15 no Pulse
b) Python Module controller S2A.closestHitObjectToObject
connected a) with b) and your camera actuator.

Keep in mind, the actuator will not be deactivated by this method. You will need other controllers to do that (message sensor -> AND -> Camera actuator).

I hope it helps


you can also add the near sensor to the armature and connect it with the focal point controlle via inter object connection (select both objects - connect the logic blocks)

I’ll remember that, thanks

Oh, gosh…now I feel silly. Thanks for spotting that oversight.

All right cool, I’ll implement the adjustments you suggested.

Wait…you can connect logic blocks across different objects??? Did I read that right? (this could save me a lot of redundant logic in my other blends)

You sir… have just upped my frame rate.

Many Thanks.

Yes you can. But it creates a bit of a logic brick chaos :wink: and it is fixed. Which means you can’t change that in-game.