- Home /
Question by
eeveelution8 · Jun 13, 2014 at 10:56 PM ·
javascriptgunjava
an object seemingly cannot access a value in other.
A drill in the game is supposed to only fire if the players fuel value is equal or greater than the cost to run it. It's strange because i've done this before, but it doesn't work for this one. anyone know what's wrong? the error is at the line,
if(fuels.fuel >= fuelcost){
var holder : GameObject;
var fuels : Playerstuff;
var reapirthing : GameObject;
var fuelcost : int = 1;
function Update () {
if(Input.GetButtonUp("Fire1")){
if(fuels.fuel >= fuelcost){
fuels.fuel = fuels.fuel - fuelcost;
var instance : GameObject = Instantiate(reapirthing, transform.position, transform.rotation);
}
}
}
function Start(){
holder = GameObject.FindGameObjectWithTag("Player");
fuels = holder.Playerstuff;
}
Comment
Best Answer
Answer by fafase · Jun 13, 2014 at 11:09 PM
I assume Playerstuff is a component so you need to use GetComponent in the Start.