- Home /
Other
send message by networking
Hi, again, i'm here because i have a problem, i'm trying to access to a networkplayer, how can i send message by networking i've tried this but i get an error, here's the code
function OnTriggerStay(otro : Collider)
{
if(otro.gameObject.tag == "Player")
{
if(otro.GetComponent(MovimientoJugadorBasico)){
if(modoAtaque){
if((Input.GetButtonUp("punch") || Input.GetButtonUp("kick")))
//otro.GetComponent(MovimientoJugadorBasico).recibirAtaque(modoAtaque,hit);
var viewID = otro.collider.networkView.viewID;
networkView.RPC("aplicar",RPCMode.All,viewID,otro.gameObject.name);
}
otro.GetComponent(MovimientoJugadorBasico).herido = modoAtaque;
}
}
}
and the RPC function
@RPC
function aplicar(id : NetworkViewID, d : String)
{
var enID = NetworkView.Find(id);
var en = enID.observed.gameObject;
en.gameObject.SendMessageUpwards("recibirAtaque",hit,SendMessageOptions.DontRequireReceiver);
}
if you know other way, please help me
"i've tried this but i get an error" and you didn't post the error why?
Note that an RPC call can only be received by the same script or other scripts that belong to the same object.
Just to make sure check that you have a networkView attached to your GameObject
Follow this Question
Related Questions
Implementing a news feed into my application 1 Answer
Going from LAN to WAN (UNet Online) 2 Answers
Network Communication - sending packets without RPC/NetworkView? 0 Answers
Is the master server down? 0 Answers
Testing my multiplayer character offline 0 Answers