elastic, what I mean is I want a script that can be used on multiple objects with different variables for example lets say you pick up an item and it says
something like this
Item1
garbage
9999
and another like this
Item2
Trash
1 1/2
is it possible to take a single script and use it on multiple game Objects and still be able differentiate between Item1 and Item2??? this just would take a whole lota weight off my shoulders
just make sure in your script you have
var itemID : string;
var description : string;
var amount : float;
Then you can drag the script to each object in the game and it will use the variables but you can set them for each object.
But if I have two Items using the same script trying to display the info of the script then how to I differentiate script from script if I use
(Inventory.js)
var ItemScript : Item;//Item is the script Item.js
var Name = ItemScript.Name;
blah blah
(Item.js)
var Name = "Item1";
(Item.js)another item
var Name = "Item2"
so if I want it to display the name it has either “Item1” or “Item2” to use…
In the inspector window you will see the variables for your script and per object you can set them to different variables. That way you can reuse the code in the script but give each object specific variables.
Okay, so other scripts trying to access that script wont get it confused with diffrent gameObjects… thats what I was looking for.
Thanks