#Items
1 messages · Page 1 of 1 (latest)
How I approach it is to make a script specifically to drop items, attach it to my 'managers' game object, and so when anyone or anything wants to drop an item, it just calls the static method in that script
is your managers object a singleton? how do you get the reference to it?
oh well i guess if its a static function you dont need the reference to a specific manager object
There is no downside to having static members if you are using them in ways that make sense
i guess that makes sense as far as where to organize the functions
I'm not sure what the standard way to do it is, but I create a game object and attach scripts to it that serve general functions for the scene. So one could be 'ItemDropper', and have a public static method called DropItem(gameobject item, vector3 position), and then when a player or building wants to drop an item, their script calls ItemDropper.DropItem(myitem, myposition)
i should probably move the dropItem function to either the items class or the inventory class or something like that
If the function requires zero data from an instance of the class it is inside of, you might as well make it static
thanks danon
thats what i was hoping, but i didn't know if static functions made a huge performance hit or something like that
😐