So I’m wondering if somebody could help me with this, I’m basically trying to create a script that allows NPC’s to be part of the same group based on a value.
This is using the script
public enum groupNumber {
One,
Two,
Three,
Four,
Five,
}
public groupNumber Group;
I need to write a script that reads the value of that whatever is “selected” and create and output.
The basic idea I have for this would be (I’m quite new to coding so please pardon the pseudo code.)
if Group (One) = don’t attack anyone who is Group (One)
if Group (Two) = don’t attack anyone who is Group (Two)
I have no idea how to write this or even if an enum is the best thing to use for this situation.
I think tags are the recommended way of doing this.
For the “who likes who” you’ll need a 2D grid. I’ve been trying to find an example (I know NWN uses one in the editor), but my google-fu has failed me.
It’s the same idea as the physics Layer Collision Matrix in Unity though.
Go to: Edit => Project Settings => Physics
EDIT: Unless you just want the groups, then use tags.
public class npc
{
public enum groupNumber {
One,
Two,
Three,
Four,
Five,
}
public groupNumber Group;
}
public class help : MonoBehaviour
{
public List<npc> enemyList = new list<npc>();
void checkNPCGroup()
{
npc n = enemyList[0];// or whatever npc class you want
if(npc.groupNumber == n.Group)
{
// do whatever a same group npc would do.
}
else
{
//do whatever if not in same group
}
}
}