Question by
LucarioOfLegends · Jul 02, 2018 at 01:35 AM ·
cameraupdatetags
Can't recheck for object with Tag after object with tag has changed.
Hi!
I'm creating a game where the player switches between different forms (which in this case are seperate entities) which also changes which object has the "Player" tag. My camera system checks at the start of the scene who intially has the tag, but I am struggling to find a way to re-check the tag once the object with the tag has changed. I've tried in my code to do something like it, but with no success.
Here's my code:
public Transform player;
public GameObject formChangeobj;
private Transform_Manager transScript;
private bool changer;
// Use this for initialization
void Start () {
player = GameObject.FindWithTag("Player").GetComponent<Transform>();
cameraBox = GetComponent<BoxCollider2D>();
transScript = formChangeobj.GetComponent<Transform_Manager>();
changer = transScript.isChanging;
}
// Update is called once per frame
void Update () {
if (changer)
{
player = GameObject.FindWithTag("Player").GetComponent<Transform>();
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612165847im_/https://answers.unity.com/themes/thub/images/avi.jpg)