Search Unity

standard asset script is broken, how do I fix it?

Discussion in 'Scripting' started by digitaldebonaire, May 29, 2013.

  1. digitaldebonaire

    digitaldebonaire

    Joined:
    May 29, 2013
    Posts:
    4
    I am very new to unity. I just finished a tutorial on unity cookie and told it to play and I got a bunch of compiler errors all coming from the standard assets scripts. I managed to fix all but one. In Assets/Standard Assets/Scripts/General scripts/ActivateTrigger.cs I get CS0131: left hand side of an assignment must be a variable, a property or an indexer. This is the code

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class ActivateTrigger : MonoBehaviour {
    5.     public enum Mode {
    6.         Trigger   = 0, // Just broadcast the action on to the target
    7.         Replace   = 1, // replace target with source
    8.         Activate  = 2, // Activate the target GameObject
    9.         Enable    = 3, // Enable a component
    10.         Animate   = 4, // Start animation on target
    11.         Deactivate= 5 // Decativate target GameObject
    12.     }
    13.  
    14.     /// The action to accomplish
    15.     public Mode action = Mode.Activate;
    16.  
    17.     /// The game object to affect. If none, the trigger work on this game object
    18.     public Object target;
    19.     public GameObject source;
    20.     public int triggerCount = 1;///
    21.     public bool repeatTrigger = false;
    22.    
    23.     void DoActivateTrigger () {
    24.         triggerCount--;
    25.  
    26.         if (triggerCount == 0 || repeatTrigger) {
    27.             Object currentTarget = target != null ? target : gameObject;
    28.             Behaviour targetBehaviour = currentTarget as Behaviour;
    29.             GameObject targetGameObject = currentTarget as GameObject;
    30.             if (targetBehaviour != null)
    31.                 targetGameObject = targetBehaviour.gameObject;
    32.        
    33.             switch (action) {
    34.                 case Mode.Trigger:
    35.                     targetGameObject.BroadcastMessage ("DoActivateTrigger");
    36.                     break;
    37.                 case Mode.Replace:
    38.                     if (source != null) {
    39.                         Object.Instantiate (source, targetGameObject.transform.position, targetGameObject.transform.rotation);
    40.                         DestroyObject (targetGameObject);
    41.                     }
    42.                     break;
    43.                 case Mode.Activate:
    44.                     targetGameObject.SetActive = true;
    45.                
    46.                     break;
    47.                 case Mode.Enable:
    48.                     if (targetBehaviour != null)
    49.                         targetBehaviour.enabled = true;
    50.                     break; 
    51.                 case Mode.Animate:
    52.                     targetGameObject.animation.Play ();
    53.                     break; 
    54.                 case Mode.Deactivate:
    55.                     targetGameObject.SetActive = false;
    56.                     break;
    57.             }
    58.         }
    59.     }
    60.  
    61.     void OnTriggerEnter (Collider other) {
    62.         DoActivateTrigger ();
    63.     }
    64. }
    65.  
    the error is supposedly on line 43 and 54 where it says targetGameObject.SetActive = false;
    I guess there is something wrong with targetGameObject? I did not write this script, the unity developers did and I am not quite proficient enough in C#.
    Anyone know how to fix this?
     
    Last edited: May 29, 2013
  2. Gigabeat

    Gigabeat

    Joined:
    Feb 26, 2011
    Posts:
    85
    Change 43 to
    Code (csharp):
    1. targetGameObject.SetActive (true);
    and 54 to
    Code (csharp):
    1. targetGameObject.SetActive (false);
    :)
     
  3. digitaldebonaire

    digitaldebonaire

    Joined:
    May 29, 2013
    Posts:
    4
    That fixed it. Thanks a bunch!