0

I am building a horse racing game in Unity3D, I have problem with camera: Currently, my camera only focuses on one fixed horse (ex, horse No 1), so it causes when this horse is far away from others then there will be only one horse appeared on screen, it is not good solution. Anybody has some ideas on this? Thanks,

Bruce Vo
  • 45
  • 1
  • 8
  • Many questions here regarding this, but this isn't really a programming question. You are asking for logic on how to implement this camera system. You need to come up with the rules you want, then you try to implement the code. Only at that stage can we try to help you, if you are having problems. There may be better, alternative, places to ask this question as it is, like http://gamedev.stackexchange.com – anothershrubery Jul 01 '14 at 09:32
  • Naive solution for a single camera: find the bounding box of all the horses, point the camera at the middle of that box, and adjust the zoom so that all the horses are visible. – RichieHindle Jul 01 '14 at 10:10
  • Thanks for all, Hello RichieHindle, Could you teach me that how can I find a bounding of all the horses? – Bruce Vo Jul 01 '14 at 11:20
  • 1
    @BruceVo: Not here in a comment, no. :-) It's a well-defined concept - go and search for it. – RichieHindle Jul 01 '14 at 15:18
  • @RichieHindle: Thanks so much, I will find out for this. – Bruce Vo Jul 02 '14 at 08:11

1 Answers1

1

You can think as you were making a movie: just place more cameras on the scene, and activate them one at a time. If you want a camera per horse, you could place a camera directly into the horse's prefab (assuming you have it), so that each newly instantiated horse has one of them. Then, you can write a function that permits the cameras' switch:

var cameras : GameObject[];

function SelectCamera (index : int) {
    for (var i : int = 0; i < cameras.length; i++) {
        if (i == index){
            cameras[i].camera.active = true;
        }else{
            cameras[i].camera.active = false;
        }   
    }
}
Andrea
  • 6,032
  • 2
  • 28
  • 55