Search Unity

accesing functions of other script

Discussion in 'Getting Started' started by witcher101, May 30, 2016.

  1. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    I am trying to acess a die function of other script
    Code (CSharp):
    1. public FPSPlayer fpsscript;
    2. void update ()
    3. {
    4. if (health<0)
    5. fpscript.die();
    6. }
    7.  
    8.  
    getting this error
    FPSPlayer.die' cannot be used as method or delegate

    how do i call this script??
     
  2. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I don't know what fpscript.die is. It might be helpful to show this sort of information.

    Judging by the error, it's not a method or a delegate. And you seem to want it to be.

    From your usage of it, it should look like:

    Code (CSharp):
    1. public void die()
    2. {
    3.     // code here
    4. }
    Is that what it looks like?
     
  3. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Oh sry it was actually Die instead of die.
    die was another variable in same script.
    My mistake