I've got a Mage class where they can shoot a fireball.
I've got it so that when the player decided to shoot a fireball a fireball will instantiate with a script on it that will deal with movement and damage of the fireball.
I don't want the player class to have to control or deal with the fireball in any way of than creating it.
Inside my player class is the variable _power. This variable is basically a modifier for the damage of the fireball (and later on all moves). There for my fireball class needs to know about this number to correctly apply the damage.
So, my question, is there any way to pass my _power variable into the fireball class when it is instantiated? (Sorry for any bad formatting of my question, first time I've posted here) class Mage::Player { public GameObject fireball; private void useFireball() { if (isFireBallOnCooldown){ return; } //instantiate fireball setFireballCooldown(); } }
I've got it so that when the player decided to shoot a fireball a fireball will instantiate with a script on it that will deal with movement and damage of the fireball.
I don't want the player class to have to control or deal with the fireball in any way of than creating it.
Inside my player class is the variable _power. This variable is basically a modifier for the damage of the fireball (and later on all moves). There for my fireball class needs to know about this number to correctly apply the damage.
So, my question, is there any way to pass my _power variable into the fireball class when it is instantiated? (Sorry for any bad formatting of my question, first time I've posted here) class Mage::Player { public GameObject fireball; private void useFireball() { if (isFireBallOnCooldown){ return; } //instantiate fireball setFireballCooldown(); } }