- Home /
Two-way tables. Relationship between variables
I need to set the relationship between factions in my game to "Friend", "Foe", or "Neutral", ideally from within the editor. I think a two way table with dropdown boxes could work (if it's possible), similar to the physics and physics2d in project settings. I can use this code for dropdowns:
enum myEnum // your custom enumeration
{
Item1,
Item2,
Item3
};
from here: http://answers.unity3d.com/questions/201848/how-to-create-a-drop-down-menu-in-editor.html
But how do i set the relationships between factions in editor and at runtime, and read the relationship between the factions?
Using javascript. Thanks in advance
Answer by fafase · Apr 18, 2014 at 07:19 PM
public enum myEnum // your custom enumeration
{
Item1,
Item2,
Item3
}
var myType:myEnum;
var foe:myEnum;
var neutral:myEnum;
function CheckOther(other:myEnum){
if(other == foe)// Attack
if(other == neutral)// Ignore
else // It is a friend
}
You could call the method on collision or when getting close. The object passed itself to the method so that the other can check who he is.
I know that much, but i need a two-way table sort of thing, like this:
Faction A Faction B Faction C Faction A Friend Foe Neutral ----------------------------------------- Faction B Foe Friend Friend ----------------------------------------- Faction C Neutral Friend Friendwhere each box is a dropdown. sorry if i didn't word my question properly There's something very similar in project settings/physics(and physics2d)
Your answer

Follow this Question
Related Questions
Table Counting 2 Answers
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Call Builtin Function on other GameObject 1 Answer
Save Player Health and stats 1 Answer