Question by
Jdob2000 · Jul 25, 2021 at 09:47 AM ·
scriptableobjectreferencing
How to reference GameObject from a scriptable object?
I'm trying to create an equipment system for a multiplayer game.
My player has a component called 'equipped items', which has the following members:
public WeaponEquipment weaponEquipment;
public HeadArmourEquipment headEquipment;
public ChestArmourEquipment chestEquipment;
public LegArmourEquipment legsEquipment;
public FeetArmourEquipment feetEquipment;
Each variable is a scriptable object I've created which are more or less the same:
public class HeadArmourEquipment : ArmourEquipment
{
public override void Use()
{
Debug.Log("equipping helmet");
//This is where I want to do something
}
}
I want to assign the scriptable object (HeadArmourEquipment) to the headEquipment of EquippedItems , whenever HeadArmourEquipment.Use() is called.
I can't figure out how to reference EquippedItems (which is on each player).
Also my workaround for referencing the scriptable object seems flawed:
public HeadArmourEquipment headArmourEquipment;
putting this ^ into the class, and assigning the correct asset in the editor. Surely there is a better way to do this?
Thanks in advance, please let me know if there is any info I've left out.
Comment
Your answer
