Unity Spain

Post Antiguos => General (Antiguo) => Mensaje iniciado por: Luxskkz en Marzo 09, 2017, 12:35:21 AM

Título: Atacar con espada
Publicado por: Luxskkz en Marzo 09, 2017, 12:35:21 AM
Hola, quisiera saber si alguien me podría ayudar estoy intentando de hacer que mi personaje haga daño con la espada pero me tira el siguiente error(Ver Imagen)
 

 


Este es el Script:
 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class sword : NetworkBehaviour {
public NetworkView nv;
void Start() {
nv = GetComponent<NetworkView>();
}
[RPC]
public void applyDamage()
{
//health = health - dmg;
Debug.Log ("hit");
}
public void OnTriggerEnter(Collider other){
if(other.gameObject.tag == "Player"){
nv.RPC("applyDamage", RPCMode.AllBuffered, null);
}
}
}

 
 
Título: Atacar con espada
Publicado por: francoe1 en Marzo 09, 2017, 12:56:43 AM
¿Legacy Networking? ¿Aún funciona?...
 
¿El jugador es Autoritativo?
 
¿Estas intentando armar al multijugador de esa manera?
 
 
 
 
Título: Atacar con espada
Publicado por: Luxskkz en Marzo 09, 2017, 01:24:24 AM
Investigando un poco vi de lo que hablas, así que modifique el script pero me tira un error de
 
"Trying to send command for object without authority. "
 
entonces puse el !isLocalPlayer, pero al colocarlo no ejecuta nada deja tirar el error mencionado pero no hace nada, entonces no se que hacer :c
 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class sword : NetworkBehaviour {
[Command]
void Cmdapply()
{
        //health = health - dmg;
   Debug.Log ("hit");
}
public void OnTriggerEnter(Collider other){
   if(other.gameObject.tag == "Player"){
   /*if (!isLocalPlayer) {
           return;
    }*/
      Cmdapply();
   }
}
}