Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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,744
    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,739
    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