Prof. Monster's Camera Focus

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.


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 (97.6 KB)

Thanks! this is exactly what i was looking for

Regards

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

NinjAcademy

Nice, certainly a handy setup :slight_smile: