Search Unity

How to use a function from another script inside of the Invoke () class?

Discussion in 'Scripting' started by MJG1123, May 28, 2015.

  1. MJG1123

    MJG1123

    Joined:
    Apr 12, 2015
    Posts:
    24
    watch this video please, also can I create a new function and have that function side of like this

    start()
    {
    Invoke ("example1",3);
    }


    example1 ()
    {
    otherscript.function();
    }
     
    Last edited: May 28, 2015
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I can't understand a word of what's going on in that video, but you can call invoke on other scripts:
    Code (csharp):
    1.  
    2. public MonoBehaviour otherScript;
    3. void Start() {
    4. otherScript.Invoke("example1", 3f);
    5. }
    6.  
     
  3. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    Use GetComponent to get a reference to the other object than call its method
     
  4. MJG1123

    MJG1123

    Joined:
    Apr 12, 2015
    Posts:
    24
    StarManta with the save... thank you