Si qq'un pouvait zieuter le script et voir si j'ai pas zappé qqchose, ce serait super...
J'ai appelé le fichier chopitems.js, à glisser sur le joueur.
Merci de vos suggestions, et bonne journée
Code : Tout sélectionner
#pragma strict
private var guiShow1 : boolean = false;
private var guiShow2 : boolean = false;
public var pochette1 : UnityEngine.UI.Text;
public var pochette2 : UnityEngine.UI.Text;
var chopson1 : AudioClip;
var chopson2 : AudioClip;
var score1 : int;
var score2 : int;
var zeinfo1 : Texture;
var zeinfo2 : Texture;
//-------------------------------------------------------------------------------------------------
function OnTriggerStay(other:Collider) {
if (other.tag == "Item1") {
guiShow1 = true;
if (Input.GetKeyDown("space") && other.gameObject.tag == "Item1") {
GetComponent.<AudioSource>().PlayOneShot(chopson1);
Destroy(other.gameObject, 0.4);
score1 ++;
pochette1.text = score1.ToString();
guiShow1 = false; // j'ai mis ça ici, c'est sensé faire disparaitre l'image si les 2 conditons ci-dessus sont réunis
// a savoir que le son, l'incrémentation et la disparition de l'item fonctionne, donc, je dois m'être gourré dans a "formulation" de guiShow false...
}
}
if (other.tag == "Item2") {
guiShow2 = true;
if (Input.GetKeyDown("space") && other.gameObject.tag == "Item2") {
GetComponent.<AudioSource>().PlayOneShot(chopson2);
Destroy(other.gameObject, 0.4);
score2 ++;
pochette2.text = score2.ToString();
guiShow2 = false;
}
}
}
//-------------------------------------------------------------------------------------------------
function OnTriggerExit (other : Collider) {
if(other.tag == "Item1") {guiShow1 = false;}
if(other.tag == "Item2") {guiShow2 = false;}
}
//-------------------------------------------------------------------------------------------------
function OnGUI() {
if(guiShow1 == true) {
GUI.DrawTexture(Rect((Screen.width / 2)-100, (Screen.height / 2)-100, 200, 200), zeinfo1);
}
if(guiShow2 == true) {
GUI.DrawTexture(Rect((Screen.width / 2)-100, (Screen.height / 2)-100, 200, 200), zeinfo2);
}
}