Anyone know how to fix this issue? (Java)
Here’s the part I’m stuck at. I’m trying to find a variable name from a different object (Object is the player, script on it is called “PlayerAnimationController”) I’m looking for the variable called “Facing” in said script. Then check if the Facing Variable is 0 (Left) or 1 (Right). But I’m having trouble accessing it. My error is:
Assets/_SamuraiScroller/Scripts/EnergyBar.js(83,70): BCE0020: An instance of type ‘PlayerAnimationController’ is required to access non static member ‘Facing’.
Code snipet of the problematic area:
if (Active == 2){
var Facingscript : PlayerAnimationController;
Facingscript = GetComponent("PlayerAnimationController");
audio.clip = ReleaseSound;
audio.Play();
var Spawnpoint = GameObject.Find("Special_Attack_Spawn");
var ChargeAttack = Instantiate(SpecialAttack, Spawnpoint.transform.position, transform.rotation);
if(PlayerAnimationController.Facing == 0)
{
ChargeAttack.rigidbody.AddForce(Vector3.Left * AttackSpeed);
}
if(PlayerAnimationController.Facing == 1)
{
ChargeAttack.rigidbody.AddForce(Vector3.Right * AttackSpeed);
}
Active = 1;
yield WaitForSeconds (audio.clip.length);
Active = 0;
}
}