Call RPC on another Script?

New to forum. I have a math asteroid game where I'm calling the asteroid script form my gameScript and it seems to be causing index parameter problems––not sure. "Argument out of Range Exception" Works fine without PhotonNetwork code. Here's the essence of it:
[code2=csharp]Asteroid[] asteroids = (Asteroid[])GameObject.FindObjectsOfType(typeof(Asteroid));

for(int i=0; i<asteroids.Length; i++)
{
if(asteroids)
{
PhotonView photonView = PhotonView.Get(asteroids); //// Get(this),

photonView.RPC("hitUsingSum", PhotonTargets.All , sum);

if(asteroids.hitUsingSum( sum ))
{
hitCount++;
}

print("hitUsingSum " + hitCount);
}
}[/code2]

Am I allowed to call [RPC] on another script? As you can see, I am grabbing the script class and passing it on. Is there an alternative way to do this? Also, only the master can destroy the Instantiated scene object. Thanks for any help you might offer.

Comments

  • Yes, you can call any view's RPCs, if you like.
    I don't see the issue here. The callstack might help.
Sign In or Register to comment.