Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Command not working at all

Discussion in 'Multiplayer' started by Happy_Jingle, Feb 5, 2016.

  1. Happy_Jingle

    Happy_Jingle

    Joined:
    Mar 9, 2014
    Posts:
    103
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4.  
    5. public class Bullet : MonoBehaviour {
    6.     public Hero shootHero;
    7.     public string direction;
    8.     public Player myPlayer;
    9.     // Use this for initialization
    10.     void Start () {
    11.    
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.    
    17.     }
    18.  
    19.     void OnCollisionEnter(Collision collision){
    20.         if (collision.collider.tag == "Hero") {
    21.             Hero someHero = collision.collider.GetComponent<Hero> ();
    22.             if (someHero.team != myPlayer.team) {
    23.                 Debug.Log ("request bullet damage");
    24.                 Debug.Log (shootHero);
    25.                 myPlayer.ClientRequestBulletDamage (direction, shootHero.heroIdentifier);
    26.             }
    27.         }
    28.         Destroy (gameObject);
    29.         Debug.Log ("destroyed bullet");
    30.     }
    31.  
    32. }
    33.  
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5. using UnityEngine.Networking;
    6. using System;
    7. public class Player : NetworkBehaviour {
    8.  
    9. [Client]
    10. public void ClientRequestBulletDamage(string direction, int heroID){
    11.         Debug.Log ("client requesting bullet damage from inside player");
    12.         CmdRequestBulletDamage (direction, heroID);
    13. }
    14.  
    15. [Command] //send rpc to other client form here!!!!!!!
    16. public void CmdRequestBulletDamage(string direction, int heroID){
    17.     Debug.Log ("requesting bullet damage!!!!!!!!!COMMAND!!!!!!!");
    18.  
    19. }
    20. }
    I cannot get the "requesting bullet damage!!!!!!!!!COMMAND!!!!!!!" message to fire, everything up to that point seems to work fine though. What should I do?
     
  2. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,117
    is the client prefab the owner which has Authority?
    did you tick the box in spawned prefab "has local authority"