What I’m trying to do is a build a system where the player can see a weapon on the ground, it clones a new weapon and carries all the set variables over to that clone (ammo etc), pick up the clone, and that should replace the other weapon they’re already holding.
My other game object is called Weapon Controller, and that has the script called weaponHandler, which has all the code used to hold any weapon it’s given and switch between the two of them. weaponHandler has to two variables, one for each weapon.
Any help I can get I’d appreciate :')
#pragma strict
var weapon : GameObject; //any weapon can be used here
var currentClip : float;
var currentAmmo : float;
var currentWeapon : Component;
function Start ()
{
}
function OnTriggerEnter (other : Collider)
{
print("Item is in range");
var weaponClone : GameObject = Instantiate (weapon); //clone the weapon
currentWeapon = gameObject.GetComponent(WeaponHandler); //check what weapon is in the weapon1 variable
currentWeapon.weapon1 = weaponClone; //change that current weapon to our new cloned weapon
//var currentSelected = currentWeapon.GetComponent(WeaponHandler).weapon1;
//currentSelected = weapon;
}