VintageRoots
Member
Im trying to reward 10 currency points to my character everytime he hits an enemy, in the "Character Health" component there is an event section where i can give points. So ive tried this script and gave it to my zombies:
I assigned the functions to the Events OnDamage() and OnDeath() it works perfectly, WHEN the Zombie is directly in the scene,
The Problem: My Zombies are Spawned() with Pooling which erases the GameObject when i assign it
This means, i have to find a way to recognize the Currency Owner frrom a scrript that is attached in the Zombiie Prefab
I tried my best but im breaking my head now, xD please help
using UnityEngine;
namespace Opsive.UltimateInventorySystem.Core.InventoryCollections
{
using Opsive.Shared.Utility;
using Opsive.UltimateInventorySystem.Core.DataStructures;
using Opsive.UltimateInventorySystem.Exchange;
using Opsive.UltimateInventorySystem.ItemActions;
using Opsive.UltimateInventorySystem.Storage;
public class PointsManager : MonoBehaviour
{
public static PointsManager instance;
public CurrencyOwner CurrencyOwner;
private void Awake()
{
instance = this;
CurrencyOwner = GetComponent<CurrencyOwner>();
}
public void addPoints()
{
var points = InventorySystemManager.GetCurrency("Points");
CurrencyOwner.CurrencyAmount.AddCurrency(points, 10);
}
public void zombieDeadAddPoints()
{
var points = InventorySystemManager.GetCurrency("Points");
CurrencyOwner.CurrencyAmount.AddCurrency(points, 60);
}
}
}
I assigned the functions to the Events OnDamage() and OnDeath() it works perfectly, WHEN the Zombie is directly in the scene,
The Problem: My Zombies are Spawned() with Pooling which erases the GameObject when i assign it
This means, i have to find a way to recognize the Currency Owner frrom a scrript that is attached in the Zombiie Prefab
I tried my best but im breaking my head now, xD please help