Hi, my game consists of two characters which means i have two character controllers (default). Whenever i switch cameras and move both characters move together, when i only need to move the character i am focusing on.
To switch between characters i use this code (Characters have 2 cameras each) :
Character1 > Camera 1 and 2
Character2 > Camera 3 and 4
var camera1 : Camera;
var camera2 : Camera;
var camera3 : Camera;
var camera4 : Camera;
public var startCamera : int = 1;
function Start ()
{
camera1.enabled = true;
camera2.enabled = true;
camera3.enabled = false;
camera4.enabled = false;
startCamera = 1;
}
function Update ()
{
if (Input.GetKeyDown ("c") && (startCamera == 1))
{
startCamera = 3;
camera1.enabled = false;
camera2.enabled = false;
camera3.enabled = true;
camera4.enabled = true;
}
else if (Input.GetKeyDown ("c") && (startCamera == 3))
{
startCamera = 1;
camera1.enabled = true;
camera2.enabled = true;
camera3.enabled = false;
camera4.enabled = false;
}
}
I am guessing that your character controllers are listening on user inputs and do not know if the character is actually active or not. In that case you can add a simple if-statement which checks if the character is currently active and should be moved / controlled or not.
For example you could check on the startCamera variable or define a flag in the controller script, which you turn on or off when you switch characters.