Using Currency via a tag or layermask as opposed to a GameObject.

Because prefabs do not hold the gameobject runtime conditions, is it possible to have the currency add and subtract be used via a tag or layer as opposed to a gameobject? If so, could you possible show me a sample code or directions as to where I can learn how to do this? Thank you.
 
Sorry I do not understand the question.
Could you give more context to what you are trying to achieve?
 
Sorry I do not understand the question.
Could you give more context to what you are trying to achieve?

I have a simple script I attach to my enemy that when a trigger interaction occurs, coins are removed from the Currency Owner. I have to drag the Currency Owner from the Hierachy into the enemy carrying the remove currency script. This works. However, when I spawn a prefab enemy, it is always calling for the Currency Owner to be drug back into the remove currency script. If I could make the currency owner = a tag name or even make the currency owner be a layer that is activated, I could make useable prefabs that take away the currency owners coin anytime a trigger interaction occurs.
 

Attachments

  • OPSIVE HELP 05.png
    OPSIVE HELP 05.png
    24.4 KB · Views: 6
  • OPSIVE HELP 06.png
    OPSIVE HELP 06.png
    53.2 KB · Views: 5
  • OPSIVE HELP 07.png
    OPSIVE HELP 07.png
    44.4 KB · Views: 6
  • OPSIVE HELP 08.png
    OPSIVE HELP 08.png
    35.7 KB · Views: 7
Remember, I am very new to doing any of this. If you have a much simpler way to suggest, I am always eager to learn. Again, I also am very appreciative of the support.
 
Ok, I'm not sure 100% get it. So let me know if I'm incorrect.

My understanding is that you have an object that has a currencyOwner. Each time an enemy hits (triggers) this object, you remove currency from that object, specified by the "tax" value set on the enemy.


This is a very classic interaction setup. And you'll find a ton of tutorials online on how to implement this in Unity.
This is very generic, not something specific to the inventory system.

1. in the onTrigger function, check if the collider gameobject is within the layer mask: https://forum.unity.com/threads/how...cts-layer-mask-is-in-an-if-statement.1310058/
2. Then get the CurrencyOwner gameobject on that gameobject ( collider.gameobject.GetComponent<CurrencyOwner>(); )
3. remove the currency from that currencyOwner

I hope that makes sense

PS: This video goes a bit beyond that, but I recommend it a lot. Even though it goes more in depth they explain it very well in a way that beginners can understand:
 
Top