Unity C# script to find a reference to player.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Awake () | |
| { | |
| // Setting up the reference. | |
| FindPlayer(); | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| if(player){ | |
| // Do game logic with player | |
| }else{ | |
| FindPlayer(); | |
| } | |
| } | |
| void FindPlayer(){ | |
| playerGO = GameObject.FindGameObjectWithTag("Player"); | |
| if(playerGO){ | |
| player = playerGO.transform; | |
| Debug.Log (player); | |
| setupLineRenderer(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment