hey guys, I’ve got this weapon pickup script set to a pickup object that gives the player a weapon when picked up, so far the pickup only gives one fixed weapon per single pickup and I must create a new pickup for each weapon, so what I want to do is make a mario kart style pickup where it will give a random weapon when picked up instead of each weapon needing it’s own pickup. How can I do this ? here’s the script
var MachineGun : GameObject;
var RocketLauncher : GameObject;
var Unarmed : GameObject;
var UsingNothing : boolean = true;
var Using_MG : boolean = false;
var Using_RL : boolean = false;
function Start(){
UsingNothing = true;
Using_MG = false;
Using_RL = false;
}
function OnTriggerEnter (other:Collider){
if (other.GetComponent.<Collider>().gameObject.name == "MachineGun Pickup"){
UsingNothing = false;
Using_MG = true;
Using_RL = false;
}
if (other.GetComponent.<Collider>().gameObject.name == "RocketLauncher Pickup"){
UsingNothing = false;
Using_MG = false;
Using_RL = true;
}
}
function Update(){
if (UsingNothing){
Unarmed.gameObject.active = true;
MachineGun.gameObject.active = false;
RocketLauncher.gameObject.active = false;
}
if (Using_MG){
Unarmed.gameObject.active = false;
MachineGun.gameObject.active = true;
RocketLauncher.gameObject.active = false;
}
if (Using_RL){
Unarmed.gameObject.active = false;
MachineGun.gameObject.active = false;
RocketLauncher.gameObject.active = true;
}
}