Assigning player in code

Instead of having an empty transform that we drag and drop the player on, is there a performance drop if we do

GameObject player;
player = GameObject.FindGameObjectWithTag(“Player”);
transform.position = player.transform.position;

or any reason why we aren’t doing it this way?

Hello There
I Am Also A Learner So I May Be Wrong But I Think Doing What You Are Saying Will Not Make Any Major Difference In Performance
I Think Doing That Will Be a good Practice Too Cuz that Will Help You Out While Working On Multiple Scene
Although You Can Make Prefab To Get Rid Of Mountain Which I Am Talking Babout

There isn’t any performance drop if you cache the player in Awake.

void Awake()

1 Like

This topic was automatically closed after 29 hours. New replies are no longer allowed.