Quantcast
Viewing latest article 1
Browse Latest Browse All 51

GUI text Messages does not show and points counter do not stop at its prefixed limit

In my game the Player has to collect apples (like Penelope collects Orbs). Everything is working OK except that the the counter of apples (should stop in 5) that continues adding apples and the warning GUI message inside the function Pickup (else statement), which does not show the message "You can't carry any more apples". Thanks in advance for any help.

var carrying : int; var carryLimit : int; var deposited : int; var winScore : int; var appleCollect : AudioClip;

var carriedGui : GUIText;

var depositedGui : GUIText;

var guiMessage : GameObject;

private var timeSinceLastPlay : float;

public function Start() {

timeSinceLastPlay = Time.time;
UpdateCarryingGui();
UpdateDepositedGui();

}

function UpdateCarryingGui() { carriedGui.text = "Carrying: " + carrying + " of " + carryLimit; }

function UpdateDepositedGui() { depositedGui.text = "Deposited: " + deposited + " of " + winScore;
}

function Pickup()

{ if ( carrying < carryLimit ) { carrying++; UpdateCarryingGui();
}

else
{
    var warning : GameObject = Instantiate( guiMessage );
    warning.guiText.text = "You can't carry any more apples";
    Destroy(warning, 2);
}

} function OnTriggerEnter(collisionInfo : Collider) { if(collisionInfo.gameObject.tag == "apple") { carrying++; UpdateCarryingGui(); audio.PlayOneShot(appleCollect); Destroy(collisionInfo.gameObject); } }


Viewing latest article 1
Browse Latest Browse All 51

Trending Articles