x


Camera Following Multiple Objects

Hi guys,

I've got several player-controlled objects (at least 4, perhaps more in future) on screen and a single camera. The camera needs to keep all players on screen at all times. The camera should only move a limited amount, something like the camera in Super Smash Bros., which tracks the players across a nominally 2D level, panning and zooming as necessary.

I know it will require some method of centring the camera on the group, and then some function to make sure the camera is zoomed out far enough away from the group that all four (or more) of them are in view at the same time (this should be done by moving the camera, not changing the FOV).

I'm not great at mathematics, so this makes my head hurt a bit. Any help would be greatly appreciated!

more ▼

asked Sep 26 '11 at 05:20 PM

MurrayL gravatar image

MurrayL
1 1 1 1

Just a thought; would it work to create a bounding box and encapsulate the player objects each frame, then adjust the camera to display that box in it's entirety?

That way I definitely have a centre point (Bounds.center), and can probably work out the correct distance using some basic trig?

Sep 26 '11 at 04:36 PM MurrayL
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3000
x1367
x323
x291
x42

asked: Sep 26 '11 at 05:20 PM

Seen: 893 times

Last Updated: Sep 26 '11 at 05:20 PM