Best way to store a reference to another class?

Godot Version

4.3

Question

So I have two teams, each have 11 players. On each player I want to keep a reference to its team, so I can send information to it (for example: I have to let the team know which player is selected right now). Basically I need communication going back and forth between the team and its players.

Coming from C++ I think of just keeping a reference to the team on each player: Team* referenceToTeam;
But I can’t get my head around how to do it on GDScript and even if it’s the right way of doing it.

I think in gdscript you would just store the team in a variable:

var team: Team

Thanks, I assumed that it made a copy of it instead of a reference

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.