Search Unity

I Really Need To Know How To Accesses A Int From 2 Scripts

Discussion in '2D' started by brobrotothegogo, Aug 21, 2019.

  1. brobrotothegogo

    brobrotothegogo

    Joined:
    Aug 17, 2019
    Posts:
    8
    I just don't know how to accesses a int from 2 scripts... Any Help?
     
  2. BlitzBlitzCandy

    BlitzBlitzCandy

    Joined:
    Jun 20, 2019
    Posts:
    11
    Hi! I'll try to help under couple of assumptions from that question.

    I might be wrong as it often depends how you have your scripts and objects set up.

    First of all, declare your int as public and placed it inside the constructor of your script like the int inside my script.

    Second, on the script that you want to access the file, you would need to first type the name of the script then the name of the integer you are trying to access.

    *in my case it would be:
    PlayerScript.weapon

    that line of code would constitute the int you are trying to access.

    Hope that helps!
     

    Attached Files: