Search Unity

how do i find a script component from a script.

Discussion in 'Scripting' started by puddleglum, Feb 11, 2021.

  1. puddleglum

    puddleglum

    Joined:
    May 11, 2020
    Posts:
    412
    im looking to temporarily dissable one script on a gameobject from a diffrent script in a diffrent gameobject. how do i locate the script component from within the code?
     
  2. Nubaa

    Nubaa

    Joined:
    Apr 30, 2013
    Posts:
    18
    Just use the name of the script/class you're trying to grab. So like:

    Code (CSharp):
    1. PlayerController playerScript = gameobjectThatHasIt.GetComponent<PlayerController>();
     
    Vryken and Joe-Censored like this.
  3. puddleglum

    puddleglum

    Joined:
    May 11, 2020
    Posts:
    412
    :O ooooooh thank you