mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
updated code snip
This commit is contained in:
parent
5dfc85931f
commit
4306e08eb5
@ -22,7 +22,7 @@ public class Enemy : NetworkBehaviour
|
|||||||
|
|
||||||
void OnMouseUp()
|
void OnMouseUp()
|
||||||
{
|
{
|
||||||
NetworkIdentity ni = NetworkClient.connection.playerController;
|
NetworkIdentity ni = NetworkClient.connection.identity;
|
||||||
PlayerController pc = ni.GetComponent<PlayerController>();
|
PlayerController pc = ni.GetComponent<PlayerController>();
|
||||||
pc.currentTarget = gameObject;
|
pc.currentTarget = gameObject;
|
||||||
}
|
}
|
||||||
@ -38,6 +38,7 @@ public class PlayerController : NetworkBehaviour
|
|||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
if (isLocalPlayer)
|
||||||
if (currentTarget != null)
|
if (currentTarget != null)
|
||||||
if (currentTarget.tag == "Enemy")
|
if (currentTarget.tag == "Enemy")
|
||||||
if (Input.GetKeyDown(KeyCode.X))
|
if (Input.GetKeyDown(KeyCode.X))
|
||||||
@ -47,6 +48,7 @@ public class PlayerController : NetworkBehaviour
|
|||||||
[Command]
|
[Command]
|
||||||
public void CmdShoot(GameObject enemy)
|
public void CmdShoot(GameObject enemy)
|
||||||
{
|
{
|
||||||
|
// Do your own shot validation here because this runs on the server
|
||||||
enemy.GetComponent<Enemy>().health -= 5;
|
enemy.GetComponent<Enemy>().health -= 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user