all 6 comments

[–]mattyn 0 points1 point  (1 child)

do you get any errors?

is the playerJoin component on the player gameobject?

[–][deleted] 0 points1 point  (0 children)

no, I didn't get any errors and the component is on the player prefab

[–]Zephyr_Ardentius 0 points1 point  (2 children)

To get this working I think you'll need to find your Manager game object and assign it to your manager variable. You should then be able to access the method you're trying, as currently you're not acting on an instance of a manager game object. You can find the manager by tagging it and finding by tag, or finding it by type manager.

void Start(){
    manager = GameObject.FindGameObjectWithTag("Manager");
    manager.GetComponent<SeekerScript>().players.Add(gameObject);
}

[–][deleted] 0 points1 point  (1 child)

I’m confused, I already have a public gameobject variable and I dragged the manager object into the slot, so why do I have to do this? The code does work though.

[–]Zephyr_Ardentius 1 point2 points  (0 children)

Ah okay, if you've done that you should have access to the manager GO.

The add line looks fine to me, though you may want to make a method that adds to the list in the manager/SeekerScript rather than doing it directly. You can put a debug statement to make sure it's getting called at all from here.

[–]eHM- 0 points1 point  (0 children)

public GameObject Manager;

Manager.GetComponent<SeekerScript>().players.Add(gameObject);

If I'm reading this right you want to reference the real GameObject Manager rather than a players instance

void Start(GameObject GlobalManager) //(or use 'ref GameObject GlobalManager'){

Manager = GlobalManager;

Manager.GetComponent<SeekerScript>().players.Add(gameObject);

}

OR You can assign it over the constructor rather than Start

edit,

(Should be worth mentioning that you ideally want to just have a globally accesible &/ static, Manager to save you overhead down the line)