Camera Switcher in Unity - using Animation

Hopefully this might be useful to some others.... I'm still getting to grips with Unity.

This is a simple approach to cut between multiple cameras in Unity using the animation timeline - to help create cinematics / machinima.

1) Create an Empty Gameobject - I named it CamSwitcher

2) Make a new Javascript - I called mine  'CamSwitch' - and place the javascript below into it :

var cam1 : Camera; 
var cam2 : Camera; 
var cam3 : Camera; 


function SwitchCam1() 
{ cam1.enabled = true; cam2.enabled = false; cam3.enabled = false; } 


function SwitchCam2() 
{ cam1.enabled = false; cam2.enabled = true; cam3.enabled = false; } 


function SwitchCam3() 
{ cam1.enabled = false; cam2.enabled = false; cam3.enabled = true; }

follow the logic of the script if you want to add more cameras - for example


var cam4 : Camera;
function SwitchCam4()
{ cam1.enabled = false; cam2.enabled = false; cam3.enabled = false; cam4.enabled = true; }

3) Place the script into the CamSwitcher Object

4) Connect up your Multiple Cameras from your Scene in the Inspector of the CamSwitcher


5) Create an Animation File for the CamSwitcher Object, then using the Event tags - choose a frame on the timeline when you want to switch the camera.


choose the appropriate Function to switch to that camera.

6) Play the scene and check it works.

Obviously, this trick simply enables and disables cameras at specific times based on an animation file, but used in conjuction with other camera scripts, or animated cameras, or timed with other animated events,  can help quickly construct a short edited sequence for an ingame cinematic - or producing a machinima.

Comments

  1. This blog is very good.I am impressed by your blog & mostly impressed by your Camera Switcher in Unity - using Animation. Thanks for sharing this information.

    3D animation institute in Chandigarh

    ReplyDelete
  2. The blog is really informative and I like to share it with my friends. I am impressed from your presenting skills. Thanks for this informative post.

    computer animation course

    ReplyDelete
  3. Thanks for sharing with us so good information. I can engage with so many new blog website and i read & know so many things.

    Best Fashion Designing Course in Chandigarh

    ReplyDelete

Post a Comment