Question by
Nirvanawastaken1 · Jun 18, 2016 at 09:13 PM ·
c#methodsimplecalling
[C#] Why is this method called twice?
This gets called once, and prints hello once:
void hello() {
print "hello"
}
void Start () {
hello ();
}
But this gets called twice and spawns two clones:
public GameObject targetPrefab;
public GameObject targetClone;
void spawn() {
targetClone = Instantiate (targetPrefab, new Vector3(0,2,0), Quaternion.Euler(90,0,0)) as GameObject;
}
void Start () {
spawn ();
}
I would expect both blocks of code to call their methods the same number of times, what gives?
Comment
Do you have the 2nd script attached to multiple objects?
Yes, actually I just realized that haha, I was just running the second script twice.