I am working on a game and i have a script to save the stats for characters. The same script is used for hero and for the enemies.
There are actually 2 scripts. 1st script is for game settings which makes sure that which player is to be set visible and which enemy to set visible. That script has variables like
[Header("Players")]
public GameObject LocalPlayer;
public GameObject Enemy;
Now in my 2nd script with name User_stats, i want to put target for hero = enemy and vice versa. What i am doing in my 2nd script is that i calling my 1st script (FKManage) in it by doing following code
private FKManage FKManage; Then in my void start, I am using a method named SetTarget(); which is defining these two arrays and telling them that the objects with tag player need to have Target = Enemy from the FKManage script and vice versa
GameObject[] protagonistOpponent = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject obst in protagonistOpponent)
obst.GetComponent<User_Stats>().Target = FKManage.Enemy.transform;
GameObject[] AntagonistOpponent = GameObject.FindGameObjectsWithTag("Enemy");
foreach (GameObject obst in AntagonistOpponent)
obst.GetComponent<User_Stats>().Target = FKManage.LocalPlayer.transform;
And it works fine but only in Unity editor. As soon as i build the game for Android and run it under Android, my characters don't do anything (because target is not set).
I want to know why my build is not working right as it is working in editor? Where am i making the mistake? On building the game, this is the error i get in my android logcat.