Reputation: 45
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,
Upvotes: 0
Views: 776
Reputation: 6123
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;
}
}
}
Upvotes: 1