- Home /
This question was
closed Feb 26, 2017 at 09:18 AM by
alexander9727 for the following reason:
Just saw I had posted this and I don't remember why I posted it cause it works fine when I just tested it.
Question by
alexander9727 · Jun 14, 2016 at 10:10 AM ·
findcamera follow
I can't find the gameobject that my scriptis attached to
I keep getting the error NullReference Rxception and when i click on the error it takes me to the first line in my update function. I tried changing it to transform and I'm unsure what to do now.
Transform myself;
GameObject Player;
void Start ()
{
Player = GameObject.FindGameObjectWithTag ("Player");
myself = gameObject.transform;
}
void Update ()
{
myself.position = Player.transform.position;
myself.rotation = Player.transform.rotation;
Debug.Log (gameObject.name);
}
Comment
Answer by EpiFouloux · Jun 14, 2016 at 10:41 AM
If the GameObject Player
is the one that your script is atached to, this.gameObject
should work !