Search Unity

how to change value in inspector during run time !

Discussion in 'Scripting' started by ashishkushwaha, Jul 30, 2019.

  1. ashishkushwaha

    ashishkushwaha

    Joined:
    May 12, 2015
    Posts:
    35
    Hello great people
    here is a kid asking for help ! :(

    i want to change the values of particular game object in inspector , during run time ,
    got stucked totally .......

    here all guns using single script GUN CONTROLLER , there is a variable for damage enemy called "damage" so in every guns having different damage value in inspector so that big gun can make big damage , if i want to upgrade gun by improving damage count for particular gun from upgrade panel in main menu , it affects all the guns because they are sharing same script , what should i do its annoying because i try multiple way to to make this think work but, it make me tired .
    weapon pannel.JPG
    above image is main menu here you can see bottom buttons control above images , to see gun features , and upgrade

    weapon holder.JPG
    its a snap of hierarchy where i am switching between guns during runtime

    gun controller.JPG
    gun controller script snap share by the all guns !
     
    Last edited: Jul 30, 2019
  2. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    357
    Make sure each weapon has an instance of Gun_Controller. Then use GetComponent<Gun_Controller>().