Quantcast
Channel: Questions in topic: "twice"
Viewing all articles
Browse latest Browse all 70

GetComponent Variable Referenced Twice

$
0
0
I'm making a fighting game that uses three main scripts per character. There's the stats, control, and projectile scripts. The stats and control both go within the character while the projectile script is in my projectile prefab. A variable (Character2) was GetComponent-ed from the stats script to the control script. It worked. When I did the same with the projectile script, it wouldn't set and stayed as zero. Can a variable only be referenced once to before the GetComponent action is unusable? I don't want to combine the Stats and Control scripts, but I will if I need to. UPDATE: All right. I'll try out what [Tehnique][1] is suggesting, but first, I'll paste some of my script here. This is for Stats2: var Character2 = 15; Control2 (receiving the variable works): var Character2 : int; function Update () { //Receive character variables. Character2 = GetComponent("Stats2").Character2; Projectile2 (receiving the variable does not work): var Character2 : int; function Update () { //Receive character variables. Character2 = GetComponent("Stats2").Character2; [1]: http://answers.unity3d.com/users/55334/tehnique.html

Viewing all articles
Browse latest Browse all 70

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>