How to change my character during the game

i have 4 character i want to change swap(switch) character during the game means when i pressed a key current character disappears & another character appear like Trine game.

how to do that its all done in scripting or something else. if this is all in scripting please show the scripting

Thanks

Considering your 4 characters are 4 different objects in your game that have the names C1, C2, C3, C4, you will change them by pressing the Space Bar with the following code:

var selectedCharacter : int = 1;
var characterName : String;

function Update()
{
   if(Input.GetKeyDown(KeyCode.Space))
   {
      if (selectedCharacter < 4)
          selectedCharacter++;
      else
          selectedCharacter = 1;

      for (var i = 1; i < 5; ++i)
      {
         if(i != selectedCharacter)
    	 {
    		characterName = "C" + i;
    		GameObject.Find(characterName).renderer.enabled = false;
    	 }
    	 else
    	 {
    		  characterName = "C" + selectedCharacter;
    		  GameObject.Find(characterName).renderer.enabled = true;
    	 }
      }
   }
}

This script should be attached to an Empty Game Object (call it CharacterChanger).

If you select a character in your Project Hierarchy then look at the Inspector Properties you will notice in front of the character's Mesh Renderer a box with a tick inside. When you use renderer.enabled = false or renderer.enabled = true in the code, you basically check or uncheck that box, enabling or disabling your character rendering completely in the game. So, the character you want to be visible when you start the game, should have the Mesh Renderer activated (checked), while all the others should have this unchecked. After you start the game, pressing the SpaceBar will do the job.

The code above works for changing characters without changing their positions. If you move one of the characters (which I suppose you do), the next time you disable the character and enable another, the new enabled character will appear at his last position. If you want it to appear in the same position as the character before you have to copy it's transform position and maybe rotation or even scaling, depending on your game (something like GameObject.Find(characterName).transform.position = this.transform.position). I hope this is clear enough!