I am currently having problems using a gameobject as an argument in a function.
Here is how I am trying to call the held function from another script.
Backpack.Held(0, gameObject);
below is the function in the Backpack script:
public void Held(int a, GameObject b) {
}
I have tried setting the game object into a variable which did not work. I don’t have to use this method to pass the game object.
for reference my situation is as follows:
I pick up one of many object which has the same script, when picked up I must let another(lets say it is the main) script know which gameobject has been picked up.
I suppose I could create an empty gameobject in the main script and set it as the 'pick up’s game object in the pick up script. however I would like to know if I could achieve this using my first method,(and if the second method would work)
all help is appreciated thanks