Question by
SwiftKraft · Dec 25, 2020 at 07:35 PM ·
c#scripting problemscriptableobjectif-statements
If statement not working.
I have a ScriptableObject
called "npc", I've checked my scriptable object, the bool CanAttack
is set to true for the NPC I am making, and I've tagged the other GameObject
"NPC", but it somehow does not work.
private void OnTriggerStay(Collider other)
{
if (npc.CanAttack == false || other.gameObject.tag != "NPC")
return;
Debug.Log(Target);
enemyTarget = other.gameObject.GetComponent<NPC>();
if(npc.isHostile == true)
{
if (enemyTarget.npc.isHostile == false)
{
Target = enemyTarget;
}
}
else
{
if (enemyTarget.npc.isHostile == true)
{
Target = enemyTarget;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to convert object types? 0 Answers
Assign ScriptableObject (Inventory DataBase) 0 Answers
Problems with if-statements (C#) 1 Answer