Trying to make a character selection function.

Hey everyone,

I’m trying to figure out how to allow the player to change characters but I’ve run into a bit of a snag. I think my problem is based on the way I organize code I’ve written so I’m not really looking for specific code examples but more of a conceptual answer or a point toward a tutorial that might help. I’m relatively new to Javascript or any sort of computer language so bear with me here.

I started a small game to exercise what I was learning from basic Javascript tutorials and it really only runs in the unity application (haven’t learned to make different states or builds yet). I’ve been reiterating parts of it every day or so as I learn how to use unity and Javascript. So far, the game is only GUI elements and has the player using 3 different characters to battle a monster (kind of how fights carried out in a really old RPGs). Each of the 3 characters and the monster all have their functions and GUI elements within 3 separate .js files. I also made a manager .js file that I put the update function, everything that needs to be checked every frame and anything else that isn’t character or monster specific into. With the next iteration I wanted to learn how to add a start menu screen that allows the player to put together a group of these 3 characters I made and then a win/lose screen. The problem is that currently I need to declare variables in each of my scripts to instantiate each of the scripts and I have no idea how to replace that with a function.

So basically at the beginning of each of the scripts I have a couple lines that look like this;

 var partymem1 : Fighter;
var partymem2 : Cleric;
var partymem3 : Wizard;
var fmanager : Manager;

and within each script are some functions that change variables in the other scripts.

I want to be able to have a script to run on the front end or main menu state that will allow the player to have any arrangement of the characters they want. Is this possible or did screw up and need to rewrite a bunch of stuff? Thanks in advance!

Does Not Compute - lol. You could try the character tutorial in the resources section of the site, or something like this may work
( http://forum.unity3d.com/threads/70715-Replace-Character-Ingame )