Hi,
I need some help With my Upgrade script.
Im using the FPS constructor from the asset store and it comes With a Upgrade script, for Things for example a Scope or a rail/front grip .
But it only allows you too have 1 Upgrade equiped at once and i think this is because it uses a boolean, it must be true or false. so the Publisher said on their documentation forum that you have too change it too a float value or a init if you want too have multipli Upgrades at once.
Their site is Down, and the Publisher have moved on and can not be contacted anymore.
And im having problems With having all the gear equipped at once on a rifle.
So what is the difference between float and init ?
And will it be easy to change the boolean With a float or init?
I got this package when it was 70$, but its free now, so im gonna upload the script.
Upgrade Script
@HideInInspector var applied : boolean = false;
var owned : boolean = false;
var locked : boolean = false;
var upgradeType : String;
var upgradeName : String;
var description : String = "Upgrade Locked";
var lockedDescription : String;
var buyPrice : float;
var sellPrice: float;
var scriptID : int = 0;
var showInStore : boolean = true;
private var gScript : GunScript;
function Start () {
Init();
}
function Init () {
var gscripts = this.transform.parent.GetComponents.<GunScript>() as GunScript[];
for(var q = 0; q < gscripts.length; q++){
if(q == scriptID){
gScript = gscripts[q];
}
}
}
function ApplyUpgrade () {
var upgrades : Upgrade[];
upgrades = this.transform.parent.GetComponentsInChildren.<Upgrade>();
for(var i = 0; i < upgrades.length; i++){
if(upgrades.upgradeType == upgradeType && upgrades != this)
upgrades.RemoveUpgrade();
}
if(applied)
return;
this.SendMessage("Apply", gScript);
applied = true;
this.SendMessageUpwards("ApplyUpgrade");
}
function ApplyUpgradeInstant () {
if(applied)
return;
BroadcastMessage("TempInstant");
ApplyUpgrade();
}
function RemoveUpgrade () {
if(!applied)
return;
this.SendMessage("Remove", gScript);
applied = false;
}
function RemoveUpgradeInstant () {
if(!applied)
return;
this.SendMessage("TempInstant");
RemoveUpgrade();
}
function DeleteUpgrade () {
RemoveUpgrade();
Destroy(gameObject);
}
GrapichObjectScript
```
*var obj : GameObject;
var val : boolean = true;
var instant : boolean = false;
private var cache: boolean;
private var applied : boolean = false;
private var tempInstant : boolean = false;
function Apply () {
cache = obj.activeSelf;
if(val){
obj.SetActive(true);
} else {
obj.SetActive(false);
}
var gos = obj.GetComponentsInChildren(Renderer);
var go : Renderer;
if(!instant && !tempInstant) {
for(go in gos){
go.enabled=false;
}
} else {
for( go in gos){
go.enabled=true;
}
}
tempInstant = false;
transform.parent.BroadcastMessage("reapply", SendMessageOptions.DontRequireReceiver);
}
function Remove () {
obj.SetActive(cache);
if(instant || tempInstant){
var gos = obj.GetComponentsInChildren(Renderer);
var go : Renderer;
for( go in gos){
go.enabled=true;
}
tempInstant = false;
}
}
function TempInstant () {
tempInstant = true;
}
_```*_