I have the following method to spawn a GameObject (which is being fired on RMB).
void SpawnProjectile(string SpellName)
{
Vector3 spawnLocation = transform.Find("ProjectileSpawnLocation").transform.position;
GameObject go = (GameObject)PhotonNetwork.Instantiate(SpellName, spawnLocation, transform.rotation, 0);
Projectile projectile = go.GetComponent<Projectile>();
projectile.totalRange = projectile.BaseRange + spell.getSpellLevel();
projectile.totalDamage = projectile.BaseDamage + spell.getSpellLevel();
go.name = SpellName;
projectile.Instigator = gameObject;
projectile.enabled = true;
}
This works fine for the master client, however, when I do this on a client, variables aren’t right and it gives errors like e.g. Null reference on Instigator, because I’m checking on the OnCollisionEnter if the Instigator is not equal to the collision object.
What can I do to make this work for all connected clients? Thanks in advance!