I’m trying to get how to make this.
I have my collectible item which have special value
But they all have one script and their value is typing in unity hierarchy
How can I can the specific value in script?please explain
Maybe “this” method or something like it…
Wouldn’t it be better to have Collectibles script with a List or Array that holds all the Collectible objects instead of two instances of that Script on the GameObject?
Not really sure what you are looking after but to recieve values and other commands from a gameobject with a script attached you can easily go with “GetComponent”. Kinda like this:
public GameObject theObj;
public float Value;
public void Update(){
if(Input.GetKeyDown(KeyCode.E)
{
Value = theObj.GetComponen<The Script>().Value;
}
}