I am bad in explaining
I am working on a pickup system in which there is a gun script. i have 2 weapons and 1 is AR which have Weapon Script in it and the other one is a Grappling Gun which have GrapplingGun Script now in my pickup system it only allows Weapon Script but i want it to allow GrapplingGun script too i cannot make a seperate script for the Grappling gun because in the first script the slot data is put but if i use another it will create another slot meaning i can have both the guns but i want only 1.
Hope anyone can understand me.
My Script link [https://hastebin.com/ohefeqeguk.csharp]
You should handle the picking-up of objects in a way that works regardless of what script the gun has. For example, a player script for picking up objects, instead of a function in the weapons script and grappling gun script for being picked up.
I had a question quite similar to this and I created a class that does an initial check on what scripts the object that is being searched on has, and then I can run functions that all scripts have from one script.
A simpler way to enable the script is to essentially go:
if (EquippedObject.GetComponent<WeaponsScript>() != null)
// Has weapon script
EquippedObject.GetComponent<WeaponsScript>().enabled = false;
else if (EquippedObject.GetComponent<GrapplingGun>() != null)
// Has grappling script
EquippedObject.GetComponent<GrapplingGun>().enabled = false;
Again, I would go for the above option, and find a way to disable the gameobject that has been equipped, regardless of what script it has.
Oh thanks for the brief discription
I detect what object i pick by radius if the object with weapon script is under the player radius and i Press E(Pickup Command) it is supposed to be picked
and the second point i think there will be 2 objects if 1 is filled the other will be disabled