Hi! Now I'm sure there isn't an official Inventory Engine integration or anything like that but I have done well so far but I have hit a snag which I'm hoping is just because I am a novice missing something:
I am trying to make the HealthBonusItem script get the component from the Character Health to heal the player on item use. I had this working perfectly fine before I upgraded the inventory system by following the documentation, but now I can't seem to get the script to talk to the "Opsive.UltimateCharacterController.Traits" on use and complete the Heal function. I stare at it for ages but I can't pick myself why this one won't see it but my others would. I know both the TPCC and the Inventory Engine are working fine up to this point, and I get the debug.log of the item being used so I just need to get that action of healing happening.
Maybe there is a better way I can go about it?
The unity console has this error currently:
Assets\InventoryEngine\Demos\PixelRogue\Scripts\Items\HealthBonusItem.cs(6,14): error CS0234: The type or namespace name 'UltimateCharacterController' does not exist in the namespace 'Opsive' (are you missing an assembly reference?)
The Code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using MoreMountains.Tools;
using System;
using Opsive.UltimateCharacterController.Traits;
namespace MoreMountains.InventoryEngine
{
[CreateAssetMenu(fileName = "HealthBonusItem", menuName = "MoreMountains/InventoryEngine/HealthBonusItem", order = 1)]
[Serializable]
/// <summary>
/// Demo class for a health item
/// </summary>
public class HealthBonusItem : InventoryItem
{
[Header("Health Bonus")]
[SerializeField] protected GameObject m_Character;
public int HealthBonus;
public override bool Use()
{
base.Use();
var health = m_Character.GetComponent<Health>();
health.Heal(HealthBonus);
Debug.LogFormat("increase character's health by "+HealthBonus);
return true;
}
}
}
Thanks very much!
I am trying to make the HealthBonusItem script get the component from the Character Health to heal the player on item use. I had this working perfectly fine before I upgraded the inventory system by following the documentation, but now I can't seem to get the script to talk to the "Opsive.UltimateCharacterController.Traits" on use and complete the Heal function. I stare at it for ages but I can't pick myself why this one won't see it but my others would. I know both the TPCC and the Inventory Engine are working fine up to this point, and I get the debug.log of the item being used so I just need to get that action of healing happening.
Maybe there is a better way I can go about it?
The unity console has this error currently:
Assets\InventoryEngine\Demos\PixelRogue\Scripts\Items\HealthBonusItem.cs(6,14): error CS0234: The type or namespace name 'UltimateCharacterController' does not exist in the namespace 'Opsive' (are you missing an assembly reference?)
The Code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using MoreMountains.Tools;
using System;
using Opsive.UltimateCharacterController.Traits;
namespace MoreMountains.InventoryEngine
{
[CreateAssetMenu(fileName = "HealthBonusItem", menuName = "MoreMountains/InventoryEngine/HealthBonusItem", order = 1)]
[Serializable]
/// <summary>
/// Demo class for a health item
/// </summary>
public class HealthBonusItem : InventoryItem
{
[Header("Health Bonus")]
[SerializeField] protected GameObject m_Character;
public int HealthBonus;
public override bool Use()
{
base.Use();
var health = m_Character.GetComponent<Health>();
health.Heal(HealthBonus);
Debug.LogFormat("increase character's health by "+HealthBonus);
return true;
}
}
}
Thanks very much!
Last edited: