Skip to content

Instantly share code, notes, and snippets.

@coreysnyder04
Created July 28, 2014 13:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Unity C# script to find a reference to player.
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