Question by 
               AnthMurphy · Feb 07, 2017 at 02:38 PM · 
                javascriptobjectscharacter customizationshowinghiding  
              
 
              Hide and Show objects cycle
So I'm building a system for displaying my modular character pieces. Meaning I want to cycle through each torso piece for example, by hiding the previous one and showing the new one, but I'm no programmer.
I created a simple script which adds to a int when D is pressed and takes away when A is pressed, when the int is 1 hide the torso and when the int is 2 hide the current torso and run the torso2 script. I've got it to work on just one torso but not sure what to do with multiple. Heres my code:
 #pragma strict
 private var rend: Renderer;
 private var myInt: int = 1;
 function Start () {
     if (Input.GetKeyDown(KeyCode.D))
     {
         myInt++;
     }
 
     if (Input.GetKeyDown(KeyCode.A))
     {
         myInt--;
     }
     if (myInt == 1)
     {
         rend = GetComponent.<Renderer>();
         rend.enabled = true; 
     }
     if (myInt == 2)
     {
         rend = GetComponent.<Renderer>();
         rend.enabled = false;
         Torso2();
     }
     
 }
 
               Torso2 is just the same script but when the int is 1 it will go back to torso, or 2 it will go up to torso3.
It doesn't seem to be doing anything and I get the error message "You are trying to create a MonoBhevariour using the 'new' keyword".
               Comment
              
 
               
              Your answer