Cheo
Active member
Hello, this is a strange situation : I was able to create a simple item script which contains the Pickup function, which can be called at any moment to give the player character a weapon or some ammo, which works as intended in the editor, but not in the build !
Here's my script :
To be sure it wasn't due to a mistake on my own character I duplicated the UCC demo scene, attached it to Nolan and tested both in the editor and in the build with immediateEquip turned off and then on. Once again, it worked as expected in the editor but did nothing in the build. I really fail to see why this script could only work in the editor, could someone please help me with this ? Thanks in advance.
Here's my script :
C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Inventory;
using System.Collections.Generic;
using Opsive.Shared.Events;
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
using Opsive.UltimateCharacterController.Items;
public class MyItemScript : MonoBehaviour
{
public List<ItemPickupData> pickups;
public void Start()
{
inventory = GetComponent<InventoryBase>();
}
public void CallPickup(string name)
{
foreach (ItemPickupData p in pickups)
{
if (name == p.name)
{
inventory.Pickup(p.itemType, p.amount, p.slotID, p.immediateEquip, p.forceEquip);
break;
}
}
}
}
[System.Serializable]
public class ItemPickupData
{
public string name;
public ItemType itemType;
public int amount;
public int slotID = -1;
public bool immediateEquip;
public bool forceEquip;
}
To be sure it wasn't due to a mistake on my own character I duplicated the UCC demo scene, attached it to Nolan and tested both in the editor and in the build with immediateEquip turned off and then on. Once again, it worked as expected in the editor but did nothing in the build. I really fail to see why this script could only work in the editor, could someone please help me with this ? Thanks in advance.