Most efficient way to do controller/camera switching for turn based rpg?

I am doing a turn based rpg so I need to switch control and camera functions between characters. I have considered a few options… I could make a separate controller/camera object for each character and only keep one active at a time; or I could have one camera and controller and change its active GameObjects to the character I need; Or I could assign the meshes and cameras as a child of the controller in code maybe? My most important consideration is performance optimization… what would be the ideal method?

make a bunch of objects (your characters) and tag them with the default “Player” tag for this to work, of course you will change this to suit your needs. just a brief idea.

using UnityEngine;
using System.Collections;

public class camSwitch : MonoBehaviour {

	// Use this for initialization
	int numOfPlayers = 0; // how many players to loop through
	int currentPlayer = 0; //the current player selected.
	Vector3 camTransform = new Vector3(0,2,-4); // the camera position relative to the currently selected player
	GameObject[] players;
	void Start () {
	players = GameObject.FindGameObjectsWithTag("Player"); //get all gameobjects tagged with "player"
	numOfPlayers = players.Length-1; //set numOfPlayers to the length of the players[] array
	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown(KeyCode.A))
			transform.position = players[currentPlayer].transform.position + camTransform;
			currentPlayer ++;//increment the currentplayer value
			if (currentPlayer > numOfPlayers)
				currentPlayer = 0; // set to 0 to loop through players again

edit: attach this to your camera :slight_smile: