- Home /
Question by
Nick_Rizzo · Jul 23, 2017 at 07:09 PM ·
c#networkingnetworknetworkplayer
[Command] not working UNET
I get all the debug statements from the shoot function but nothing from the cmd whats wrong?
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class Pistol_Multiplayer : NetworkBehaviour {
public LayerMask mLayerMask;
public Transform ShootPoint;
[Command]
void CmdPlayerShot(string ID, int damage){
Debug.Log ("hit" + ID );
PlayerData _player = GameManager.GetPlayer (ID);
_player.RpcHarm (damage);
}
void Update () {
if (Input.GetMouseButtonDown (0)) {
Shoot ();
}
}
[Client]
void Shoot(){
Debug.Log ("Clicked");
RaycastHit hit;
Debug.DrawRay (ShootPoint.position, ShootPoint.forward * 100, Color.green);
if (Physics.Raycast (ShootPoint.position, ShootPoint.forward, out hit, 999f, mLayerMask)) {
Debug.Log (hit.collider.tag);
if (hit.collider.tag == "Player") {
Debug.Log ("PlayerHit");
CmdPlayerShot (hit.collider.name,10);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiplayer Moving Bullet 1 Answer
Network Game Player reference 0 Answers
Networking questions 0 Answers
How To Deal With Lingering Prefabs in Multiplayer Scene ? 0 Answers