Question by
kaeron73 · Sep 13, 2015 at 03:00 PM ·
scripting problemprogramming
BCE0019 'staminaBarDisplay' is not a member of 'PlayerGUI'
Okay, i have this error and i dont know what to do, here is script :
#pragma strict
private var hasAxe : boolean = false;
private var canSwing : boolean = true;
private var isSwinging : boolean = false;
var swingTimer : float = 0.7;
private var controller : CharacterController;
private var playerGUI : PlayerGUI;
function Start()
{
hasAxe = true;
controller = GameObject.Find("First Person Controller").GetComponent(CharacterController);
playerGUI = GameObject.Find("First Person Controller").GetComponent(PlayerGUI);
}
function Update()
{
//If we aren't moving and if we aren't swinging, then we idle!
if(controller.velocity.magnitude <= 0 && isSwinging == false)
{
GetComponent.<Animation>().Play("Idle");
GetComponent.<Animation>()["Idle"].wrapMode = WrapMode.Loop;
GetComponent.<Animation>()["Idle"].speed = 0.2;
}
//If we're holding shift and moving, then sprint!
if(controller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift))
{
GetComponent.<Animation>().Play("Sprint");
GetComponent.<Animation>()["Sprint"].wrapMode = WrapMode.Loop;
}
//WOODCUTTING SECTION
if(hasAxe == true && canSwing == true)
{
if(Input.GetMouseButtonDown(0))
{
//Stamina reduction applied to the PlayerGUI script
playerGUI.staminaBarDisplay -= 0.1;
//Swinging animation
GetComponent.<Animation>().Play("Swing");
GetComponent.<Animation>()["Swing"].speed = 2;
isSwinging = true;
canSwing = false;
}
}
if(canSwing == false)
{
swingTimer -= Time.deltaTime;
}
if(swingTimer <= 0)
{
swingTimer = 1;
canSwing = true;
isSwinging = false;
}
}
Error is in the line 44,23
Comment
Could you edit the code so that it appears properly? Or post the line 44.
Does PlayerGUI sta$$anonymous$$aBarDisplay is exist and public?
@kaeron73 Please post the PlayerGUI script as well. That would help sorting things.
I recognize the script from an earlier question. Have you coded this yourself or just used it, because at first the PlayerGUI class wasn't even present at all and now you ask for debugging the error of an non-existent variable IN PlayerGUI.
If the error says "something is not a member of something else" it's basically missing. Add it to the PlayerGUI.