- Home /
Auto loading Components?
I just recently learned how to use another script's variable via reference. Here is how i do it. Scroll all the way down for actual question.
//Script 1.cs public class NameA : MonoBehaviour {
public float variable2transfer;
variable2transfer = 1000; }
//Script 2.cs public class NameB : MonoBehaviour {
public NameA variablename; private float speed; void Start() { variablename = GetComponent (); speed = 0; }
speed = variablename.variable2transfer; }
Each time I click the PLAY button, I am required to choose the "NameA" script, so it can receive the reference and send to "NameB" script. Is it possible for me to autoload the "NameA" script, so I don't have to worry about reloading it everytime I click PLAY?
I'm not sure If I'm looking in the right places, but I've no luck finding a way to code something that connects the PLAYER into the script. The PLAYER is the name of the OBJECT containing "NameA" script; Since "NameA" is used as a controller for PLAYER.
I hope this makes sense, let me know if you need anymore information and thanks for reading.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How can I flip only my 'Player' gameobject, and l leave it's child object alone? 2 Answers
2D Gamekit broke my game 0 Answers
Condition on Character Movement 1 Answer