find localplayer instead of find with tag

currently implementing basic multiplayer into a project of mine and one of my scripts on my ui needs to access the players script to get some data. before multiplayer i used a simple findwithtag. what do i need to use now that there are now multiple players with the same tag.

i tried having the canvas spawn parented to the player and then get the script needed then unparent but that did not work very well with multiple canvases on the screen and players began sharing data which was not wanted.

any help would be be greatly apreciated

1 Answer

1

When the player gameObject instantiates, in a main/manager/static class stash a reference to the gameObject in a variable called currentPlayer. Or stash a reference to the particular script you want by calling GetComponent… on the player gameObject, and stash that. The UI then accesses this currentPlayer variable.

done something similar thanks for your help :)

–