コード例 #1
0
    private void RpcRaycast()
    {
        Ray        ray = new Ray(aimOrigin.position, aimOrigin.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            Debug.DrawLine(aimOrigin.position, hit.point, Color.red);
            if (hit.collider.tag == "Player")
            {
                CharacterCombat enemy = hit.collider.gameObject.GetComponent <CharacterCombat>();
                if (!enemy.isServer)
                {
                    enemy.CmdHurt(50);
                }
                else
                {
                    enemy.RpcHurt(50);
                }
            }
        }
    }