public void Shoot(float weaponRange, Transform origin)
    {
        Vector3 fwd = origin.transform.TransformDirection(Vector3.forward);

        Debug.DrawRay(origin.transform.position, fwd * weaponRange, Color.green, 2);

        RaycastHit hit;

        if (Physics.Raycast(origin.transform.position, fwd, out hit, weaponRange))
        {
            GameObject obj = hit.transform.gameObject;
            Debug.Log(obj.name);
            switch (obj.tag)
            {
            case "Enemy":
                var id = obj.GetComponent <OtherPlayer>().id;
                PlayerEventChannel.SendEvent(PlayerEvent.Hit(id));
                return;
            }

            PlayerEventChannel.SendEvent(PlayerEvent.Shoot());
        }
    }
Beispiel #2
0
 public void Damage()
 {
     PlayerEventChannel.SendEvent(PlayerEvent.Hit(_otherPlayer.id));
 }