# Prof. Monster's Camera Focus

**URL:** <https://blenderartists.org/t/prof-monsters-camera-focus/546591>\
**Category:** Game Engine Resources\
**Created:** [July 13, 2012, 2:42am UTC](https://blenderartists.org/t/prof-monsters-camera-focus/546591 "2012-07-13T02:42:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monster](https://blenderartists.org/user_avatar/blenderartists.org/monster/32/2958_2.png) [@Monster](https://blenderartists.org/u/Monster)\
**Post date:** [July 13, 2012, 2:42am UTC](https://blenderartists.org/t/prof-monsters-camera-focus/546591/1 "2012-07-13T02:42:26Z")

</div>

This Demo (BGE 2.63+) shows how to keep multiple object  
on screen (e.g. for brawl-games, single-screen-coop-games etc.).

In other words: How to - track multiple game objects with the camera.

This is done with three tasks:

- **A) Focus Object**  
to be placed at the middle of the tracked objects
- **B) Check Zoom**  
checking the cameras view if it should zoom in or zoom out
- **C) Camera Zooming**  
this strongly depends on your needs

**A) Focus Object**  
(see game object Camera [child of ZoomBase/Zoom])

You can have multiple focus object (e.g. for different cameras)

You can let your camera track this focus object. This option could become hand if you want to draw a including circle around the tracked objects. The focus object is the center of the circle.

Configuration  
Properties:

- “ **trackingProperty** ”  
sets the property name to identify tracked objects  
e.g. “cameraFocus” tracks all object with the property “cameraFocus”
- “ **radius** ”  
output property  
with the radius of the circle surounding all tracked objects.

**B) Check Zoom**  
(see game object Zoom [child of ZoomBase])

This object checks if the tracked objects are within certain areas of the screen.  
 ![](https://blenderartists.org/uploads/default/original/3X/1/b/1b1ad6889a00df06e54c69f8f8300f2c839f6c7b.png)  
  
ZoomOutArea:  
If a tracked object enters this area the property “zoom” is set to 1 (=ZOOM\_OUT)  
ZoomInArea:  
If all tracked objects are in this area the property “zoom” is set to -1 (=ZOOM\_IN)  
all other condition fill the property “zoom” with 0 (=NO\_ZOOM)

Be aware only the object center is measured. That means parts of the objects can be outside of the screen, without indicating a zoom.  
Be aware only the direction is returned not how fast the zoom should be.

Configuration:  
You do not need to apply this logic to the camera. You can apply it to one of its parents as well! The camera (for screen checking) will be looked up at the children)

Properties:

- “ **trackingProperty** ”  
sets the property name to identify tracked objects  
The value does not need to match the value of the focus object. It is recommended it is the same.
- “ **zoomOutArea** ”  
part of the screen where the zoom out area starts  
1.0 = whole screen (objects must leave view)  
0.0 = middle of the screen (always zoom out)  
default = 1.0
- “ **zoomInArea** ”  
part of the screen where the zoom in area starts  
1.0 = whole screen (all objects must be inside view)  
0.0 = middle of the screen (no zoom in)  
default = value from “zoomOutArea”
- “ **zoom** ”  
output property  
0 - no zoom change  
-1 - zoom in recommended  
+1 - zoom out recommended

**C) Camera Zooming**  
How you want to zoom your camera is up to you.  
You might want to

- move it around or
- play an action or
- manipulate the lens.  
etc.

The concept leaves it open how you do that.

The demo moves the parent of the camera via action. You see you can have any  
animation you like. The property “zoom” tells you if the camera should play forward  
or backward ;).

I hope you like it.

Monster

### Attachments

[CameraFocus.blend](https://blenderartists.org/uploads/default/original/3X/b/a/ba73c663c2aa163a3be578a2de73acba95b80b61.blend) (97.6 KB)

---

<div class="post-metadata">

**Author:** ![gadox13](https://blenderartists.org/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@gadox13](https://blenderartists.org/u/gadox13)\
**Post date:** [July 13, 2012, 7:32am UTC](https://blenderartists.org/t/prof-monsters-camera-focus/546591/2 "2012-07-13T07:32:39Z")

</div>

Thanks! this is exactly what i was looking for

Regards

---

<div class="post-metadata">

**Author:** ![NinjAcademy](https://blenderartists.org/user_avatar/blenderartists.org/ninjacademy/32/21917_2.png) [@NinjAcademy](https://blenderartists.org/u/NinjAcademy)\
**Post date:** [July 13, 2012, 8:09am UTC](https://blenderartists.org/t/prof-monsters-camera-focus/546591/3 "2012-07-13T08:09:03Z")

</div>

Awesome! Thanks a lot Monster! This opens up a lot more oportunities for blender game styles.

NinjAcademy

---

<div class="post-metadata">

**Author:** ![Alex\_ADEdge](https://blenderartists.org/user_avatar/blenderartists.org/alex_adedge/32/639055_2.png) [@Alex\_ADEdge](https://blenderartists.org/u/Alex_ADEdge)\
**Post date:** [July 30, 2012, 2:00am UTC](https://blenderartists.org/t/prof-monsters-camera-focus/546591/4 "2012-07-30T02:00:41Z")

</div>

Nice, certainly a handy setup 🙂
