Can anyone tell me whats happening in my code? Accessing the 2 Start() function variables in a script.
I am using 2 classes which has the variable facingRight being initialized at their own Start() functions. I created a new script to access and change the variables for my specific scene. The weird thing is one variable has been accessed and changed but the other is not? The (enemy.facing right force it to be false but the player.facing right remains to be true?) Heres the sample code:
public override void Start ()
{
enemy = GameObject.FindObjectOfType<NewEnemy> ();
successfail = GameObject.FindObjectOfType<SuccessFail> ();
menucontroller = GameObject.FindObjectOfType<MenuCtrl> ();
MyRigidbody = GetComponent<Rigidbody2D> ();
base.Start ();
this.facingRight = true;
}
public override void Start()
{
base.Start ();
this.facingRight = true;
EmptyClass.Instance.Dead += new DeadEventHandler (RemoveTarget);
kc = GameObject.FindObjectOfType<killcount> ();
ChangeState (new IdleState ());
}
void Start () {
enemy = GameObject.FindObjectOfType<NewEnemy> ();
player = GameObject.FindObjectOfType<EmptyClass> ();
player.facingRight = false;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
enemy.facingRight = false;
}
Comment