This is hard to explain but ill have a go.
In my scene i have a cube , with a tag AUG. I have another cube with the tag BE , Both have colliders set to triggers.
When i walk into the AUG trigger i want to be able to buy my AUG which i have sorted out.
When i walk into the BE Trigger , i need to buy the black eagle , also sorted out.
But for some reason , if i walk into the BE trigger , it ends up buying the AUG instead of the Black eagle
I need to be able to buy the black eagle if the tag of my trigger is BE , Same goes to AUG.
var GunOverSound : AudioClip;
var BoughtGun : AudioClip;
var buyAUG : boolean = false;
var buyBE : boolean = false;
private var StringText : String;
private var StringTextCanBuy : String;
var AUGBuyPrice: float;
var BEBuyPrice: float;
var ump1 : Vector2;
var ump2 : Vector2;
static var isBuy : boolean = false;
var changeToClass = Shoot_script.GunManager;
function Update (){
///////////////////////////////////AUG////////////////////////////////////////////////////
if( buyAUG == true ){
if(Input.GetKey(KeyCode.E) && isBuy == true && buyAUG == true && MoneyScript.CurrentMoney >= AUGBuyPrice){
MoneyScript.CurrentMoney -= AUGBuyPrice;
ChangeToAUG();
isBuy = false;
audio.PlayOneShot(BoughtGun);
}
}
if( MoneyScript.CurrentMoney < AUGBuyPrice && buyAUG == true){
StringText = "Sorry you don't have enough money
you need :" + AUGBuyPrice;
}
else
{
if(MoneyScript.CurrentMoney >= AUGBuyPrice){
StringText = “Buy AUG for” + AUGBuyPrice;
buyAUG = true;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if( buyBE == true ){
if(Input.GetKey(KeyCode.E) && isBuy == true && buyBE == true && MoneyScript.CurrentMoney >= BEBuyPrice){
MoneyScript.CurrentMoney -= BEBuyPrice;
ChangeToBE();
isBuy = false;
audio.PlayOneShot(BoughtGun);
}
}
if( MoneyScript.CurrentMoney < BEBuyPrice && buyBE == true){
StringText = "Sorry you don't have enough money
you need :" + BEBuyPrice;
}
else
{
if(MoneyScript.CurrentMoney >= BEBuyPrice){
StringText = “Buy Black Eagle for” + BEBuyPrice;
buyBE = true;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function OnTriggerEnter (col : Collider){
if( col.gameObject.tag == "AUG" ){
buyAUG = true;
isBuy = true;
audio.PlayOneShot(GunOverSound);
GunBuy = true;
}
if( col.gameObject.tag == "BE" ){
buyBE = true;
isBuy = true;
audio.PlayOneShot(GunOverSound);
GunBuy = true;
}
}
function OnTriggerExit (){
isBuy = false;
}
function ChangeToAUG (){
if( Shoot_script.isHoldingPrimary ){
Shoot_script.currentPrimary = GunManager.AUG;
}
if( Shoot_script.isHodlingSecondary ){
Shoot_script.currentSecondary = GunManager.AUG;
}
}
function ChangeToBE (){
if( Shoot_script.isHoldingPrimary ){
Shoot_script.currentPrimary = GunManager.BlackEagle;
}
if( Shoot_script.isHodlingSecondary ){
Shoot_script.currentSecondary = GunManager.BlackEagle;
}
}
Some thing is not right and im sure it has something to do with this , Thank you.