Quantcast
Channel: Answers for "Sending Damage amount to instantiate object sends previous variable"
Viewing all articles
Browse latest Browse all 4

Answer by Owen-Reynolds

$
0
0

These lines, in chargedShot (your firing function):

var chargedshot = Instantiate(ChargeTea, ... // chargedShot is my new bullet
   ...
var senddamage = ChargeTea.GetComponent (ChargeShotScript);
                   ^^^^--gets script of the PREFAB!!
senddamage.appliedDamage = CSamount; // changes damage of all future shots!!

Using ChargeTea is setting the damage of everything you spawn from now on. I'm kind of surprised it's even legal to change a prefab like that. You probably wanted to set the damage of the thing you just spawned:

var senddamage = chargedshot.GetComponent (ChargeShotScript);
                  ^^^^^--the shot I just created

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images