|
Post by jamison on Oct 31, 2017 17:48:45 GMT
Hello all, I have a problem and hopefully someone has a solution. I have been making a game with multiple levels and I have been trying to figure out a way for my enemies to attack my character in a different scene. For example, in scene 2 I have an enemy that shoots soccerballs at a target, and in the inspector I have to drag the character that they will be shooting soccerballs at and I don't know how to put something in that field from a different scene. I have made it to where my vCharacter is destroyed on load after each scene and you become a new vCharacter every scene, but then I lose all my guns from the previous scenes, but this makes it to where the enemies in the new scene will attack me. Does anyone have any suggestions? Sorry if I did a bad job explaining.
|
|
|
Post by jrackley on Oct 31, 2017 19:15:58 GMT
jamison, The easiest way to handle this is to make sure that your player has the "Player" tag and then on the script where you assign ie..(drop in the player) the player, open the script and where it is getting assigned set it to GameObject.FindObjectByTag("Player") in the start method. So if the variable to drag the Player in that script set up something like Public Gameobject Player; then in the start method add Player = GameObject.FindObjectByTag("Player"); This will automatically assign your player when the scene loads. Hope this helps you.
|
|
|
Post by jamison on Nov 1, 2017 4:51:34 GMT
jamison , The easiest way to handle this is to make sure that your player has the "Player" tag and then on the script where you assign ie..(drop in the player) the player, open the script and where it is getting assigned set it to GameObject.FindObjectByTag("Player") in the start method. So if the variable to drag the Player in that script set up something like Public Gameobject Player; then in the start method add Player = GameObject.FindObjectByTag("Player"); This will automatically assign your player when the scene loads. Hope this helps you. Thanks! This is what I was looking for.
|
|