Search Unity

scripting errors

Discussion in 'Scripting' started by Nightshade1, Feb 19, 2012.

  1. Nightshade1

    Nightshade1

    Joined:
    Feb 6, 2011
    Posts:
    95
    i made this script

    Code (csharp):
    1. var nxtlvl : boolean = false;
    2.  
    3.  
    4.  
    5. React ();
    6.  
    7. {
    8.  
    9.     nxtlvl = true;
    10.  
    11. }
    12.  
    13. function update ()
    14.  
    15. {
    16.  
    17.     if(nxtlvl)
    18.  
    19.     {
    20.  
    21.     getcomponent("Mesh Renderer");
    22.  
    23.     }
    24.  
    25. }
    and it says = should be a :

    what is wrong with it
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Theres a fair amount wrong with that script,

    Code (csharp):
    1.  
    2. React ();
    3.  
    4. // should be
    5.  
    6. function React () {
    7.  
    Code (csharp):
    1.  
    2. function update () {
    3.  
    4. // should be
    5.  
    6. function Update () {
    7.  
    Code (csharp):
    1.  
    2. getcomponent ("Mesh Renderer");
    3.  
    4. // should be
    5.  
    6. GetComponent (MeshRenderer);
    7.  
    Even with that, the GetComponent call isn't doing anything.
     
  3. Nightshade1

    Nightshade1

    Joined:
    Feb 6, 2011
    Posts:
    95
    so how do i make it render a cube then?
     
  4. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    GameObject>Create>Cube.
     
  5. Nightshade1

    Nightshade1

    Joined:
    Feb 6, 2011
    Posts:
    95
    i need to put script on the cube