Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

DontDestroyOnLoad() and GameObject.FindGameObjectWithTag() [C#]

$
0
0
Hey everybody ! I have an issue with DontDestroyOnLoad : In the First Scene, the payer have the possibility to enter in a battle, which take place in an other scene. In order to save all mobs in the battle and some other things, I use a GameObject with this code : public string currentPlayerScene; public float xPlayerPos; public float yPlayerPos; public List allAllies; public List allEnemies; void Awake() { DontDestroyOnLoad(transform.gameObject); } When the BattleScene is loaded, i have a script, named "BattleManager". In this code, there is a public GameObject for the DontDestroyOnLoad GameObject which is assigned by "GameObject.FindGameObjectWithTag("BattleSettings)" in the Start method. The problem is : the variable isn't assigned, so all the other methods can't be used. This is the Start Method of "BattleManager" : void start() { enterBattleSettings = GameObject.FindGameObjectWithTag("BattleSettings"); currentPlayerScene = enterBattleSettings.GetComponent().currentPlayerScene; xPlayerPos = -10; yPlayerPos = 10; allAllies = enterBattleSettings.GetComponent().allAllies; allEnemies = enterBattleSettings.GetComponent().allEnemies; EnterBattle(enterBattleSettings.GetComponent().allAllies, enterBattleSettings.GetComponent().allEnemies); } Thank you ! Bye, xyHeat

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>