如何让我的重叠球体起作用?

时间:2016-09-01 08:47:28

标签: unity5

这是我的错误代码:

  

Assets / Scripts / PlayerDamage.cs(166,35):警告CS0219:变量`hitCol'已分配,但其值从未使用

我不确定为什么它不能正常工作。我以为我在attackVKC下的输入函数中使用它。我应该提到这是一个统一的多人游戏。

基本上对施放攻击的玩家造成伤害,而不是对其他玩家造成伤害。我试图获得aoe(效果区域)攻击。

private Collider[] hitColliders;


    else if (Input.GetButton ("Special") && (Input.GetButtonDown ("Fire2") && offcd == true && offccd == true)) {
        attackVKC();
        StartCoroutine("GlobalCooldown");
        StartCoroutine("GlobalCCooldown");
    }

[Client]
void attackVKC(){

   hitColliders = Physics.OverlapSphere (transform.position, special.rangeVKC, mask);
        {

           if (GetComponent<Collider>().tag == PLAYER_TAG)
        {
                CmdPlayerHit(GetComponent<Collider>().name, special.damageVKC);

            }

        }
    Debug.LogError (GetComponent<Collider>().name);
    }

1 个答案:

答案 0 :(得分:0)

我实际上解决了这个问题。我没有在数组中循环,我没有意识到getcomponent是附加的游戏对象。这就是为什么它使用攻击而不是其他玩家击中玩家的原因。