diff --git a/Assets/Mirror/Examples/Tanks/Scripts/Tank.cs b/Assets/Mirror/Examples/Tanks/Scripts/Tank.cs index fe1d8af7a..fa7ad2132 100644 --- a/Assets/Mirror/Examples/Tanks/Scripts/Tank.cs +++ b/Assets/Mirror/Examples/Tanks/Scripts/Tank.cs @@ -60,16 +60,25 @@ void CmdFire() { GameObject projectile = Instantiate(projectilePrefab, projectileMount.position, projectileMount.rotation); NetworkServer.Spawn(projectile); - RpcOnFire(); + // RpcOnFire(connectionToClient); + TargetDoMagic(connectionToClient, 42); } // this is called on the tank that fired for all observers - [ClientRpc] - void RpcOnFire() + [TargetRpc] + void RpcOnFire(NetworkConnectionToClient conn) { + Debug.Log($"RpcOnFire with conn={conn}"); animator.SetTrigger("Shoot"); } + [TargetRpc] + public void TargetDoMagic(NetworkConnectionToClient target, int damage) + { + // This will appear on the opponent's client, not the attacking player's + Debug.Log($"Magic Damage = {damage}"); + } + [ServerCallback] void OnTriggerEnter(Collider other) {