Проблема с бросанием лучей в Unity

Я бросаю луч из объекта zombie в Player но луч касается только zombie

public Animator zomb;
private IEnumerator _attackCoroutine;

// Update is called once per frame
private void Start()
{
    zomb = gameObject.GetComponent<Animator>();
    _attackCoroutine = null;
}


private void Update()
{
    
    Ray r1 = new Ray(transform.position, GameObject.Find("Player").transform.position);
    RaycastHit rh1 = new RaycastHit();
    if (Physics.Raycast(r1, out rh1, 5f))
    {
        Debug.Log(rh1.transform.gameObject);
        if (_attackCoroutine == null)
        {
            
            _attackCoroutine = AttackCoroutine(rh1.transform.gameObject.GetComponent<PlayerMove>(), 10f, 10f);
            //Debug.Log("Daw");
            
        }
        
    }
}




private IEnumerator AttackCoroutine(PlayerMove pMove, float damage, float delay)
{
    Debug.Log(pMove.health);
    
    if (pMove.health > 0)
    {

        Debug.Log("dw");
        pMove.health -= damage;
        zomb.SetTrigger("attack");
        yield return new WaitForSeconds(delay);
    }
    _attackCoroutine = null;
}

Ответы (0 шт):