- Home /
This question was
closed Jul 11, 2015 at 04:52 PM by
meat5000 for the following reason:
The question is answered, right answer was accepted
Question by
Neilos · Jul 10, 2015 at 11:47 PM ·
networking
OnPlayerConnected ... The message will be ignored.
I copied the following code from the unity docs here:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
private int playerCount = 0;
void OnPlayerConnected(NetworkPlayer player) {
Debug.Log("Player " + playerCount + " connected from " + player.ipAddress + ":" + player.port);
}
}
However, without making any modifications, it gives the following error:
Script error: OnPlayerConnected
This message parameter has to be of type: NetworkPlayer
The message will be ignored.
I'm entirely confused. Is there some setup I need to do?
Comment
Best Answer
Answer by Neilos · Jul 11, 2015 at 04:49 PM
Ok I realised the problem. I had my own class called NetworkPlayer that was clobbering the NetworkPlayer that the method was expecting. I changed the name of my class (this was the easiest option).
I really should take the error messages literally, it's easy to think you know better than the machines, but we don't; Skynet will become self aware!
another option is to use void OnPlayerConnected(UnityEngine.NetworkPlayer player)