Hello everyone !
In my FPS game, I try to make a score dialog. To manage it, I have some informations in a script existing in all clients (and the server).
In the Awake() method of my player script I have these lines :
if (!this.transform.parent.networkView.isMine)
{
enabled = false;
return;
}
To be sure that all the following code won’t be called from another player.
So when one of the players has his life at 0, I call :
networkView.RPC("NewKill", RPCMode.All, Network.player, by);
The called method is the following one :
@RPC
function NewKill (dead:NetworkPlayer, killer:NetworkPlayer) {
var playersfound:int = 0;
for (var currPlayer:PlayerData in playersList.players)
{
if (currPlayer.player == dead)
{
++currPlayer.deaths;
++playersfound;
}
else if (currPlayer.player == killer)
{
++currPlayer.kills;
++playersfound;
}
if (playersfound == 2) break;
}
}
When player1 kills player2, player2 has its data in the playersList var updated. I developped a dialog which displays on the screen the playersList data. I can see that player2 has the right data, but not player1, nothing was updated in its playersList var.
With the attached debugger I saw that player1 goes into the “NewKill” method but playersList does not contain anything, but it does when I call the method to display the scores …
So I tested something else : still with the attached debugger, I added
if (!this.transform.parent.networkView.isMine)
{
enabled = false;
return;
}
at the very beginning of the 'NewKill" method. And it goes into this “if” … But my script is not disabled ! So I am in someone script but I don’t know whose (player2 has its script enabled too), in which the playersList var containes nothing.
The comportement is symmetrical : if player2 kills player1, player1 has its data updated but player2 has no changes, so this should not be a client/server - server/client problem …
Please help me !