Referencing another object's instance
I am making a bomberman-like game. I've based the structure of my game off of the tanks demo tutorial. Each player is instantiated with it's own PlayerManager script which doesn't inherit from MonoBehaviour. The PlayerActions script calls the function to set the bomb and holds a value representing powerups to the bombs explosion radius.
In my BombExplosion script I add the powerup value from PlayerActions to the default explosion radius value to get the total.
The code looks like this:
[HideInInspector] public GameObject m_BombInstance;
[HideInInspector] public GameObject m_PlayerInstance;
[HideInInspector] public PlayerActions m_BombOwner;
m_BombOwner = m_PlayerInstance.GetComponent<PlayerActions>();
m_ExplosionRadius = m_DefaultExplosionRadius + m_BombOwner.m_BombPower;
The problem is that the m_PlayerInstance is defined inside GameManager when the players are instantiated with Instantiate() like so:
m_Players[i].m_Instance = Instantiate(m_PlayerPrefab, m_Players[i].m_SpawnPoint.position, m_Players[i].m_SpawnPoint.rotation) as GameObject;
Since the PlayerManager doesn't inherit from MonoBehaviour I can't access it through that class directly. I can't figure out how I can get the bomb to reference the instance of the player that created it so that I can access the correct PlayerActions component to retrieve the powerup values and such.
How can I reference the instance for that player from the bomb script? If the bomb was created as a child of player I could get the component that way, but that seems like an incorrect way to do it.