Hello,
I was wondering, how would we give an item to the player through a specific answer in the dialogue (not related to the quest). I tried to create a script with GiveReward function that would be called through a dialogue trigger but it gives back a NullReferenceException: Object reference not set to an instance of an object. Is it because I don’t have a Getter?
using System.Collections;
using System.Collections.Generic;
using GameDevTV.Inventories;
using UnityEngine;
namespace RPG.Quests
{
public class ItemGiver : MonoBehaviour
{
public InventoryItem item;
public void GiveItem()
{
bool success = GetComponent<Inventory>().AddToFirstEmptySlot(item, 1);
if (!success)
{
GetComponent<ItemDropper>().DropItem(item);
}
}
}
}
Thanks in advance.