Game/Assets/Scripts/Player/AbstractPlayer_Attack.cs
/// <summary>
/// Casts a ray to check for target
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
Casts a ray to check for target
Casts a ray to check for target
public virtual IEnumerator DeployMeleeRay(GameObject target)
    {
        yield return new WaitForSeconds(0.5f * GetComponent<Animator>().speed);
        Vector3 forward = transform.TransformDirection(Vector3.forward);                    
        Vector3 rayVector = transform.position + new Vector3(0f, 2f, 0f);                   
        Ray direction = new Ray(rayVector, forward);                                        
        RaycastHit rayInfo;                                                                 
        if(Physics.Raycast(direction, out rayInfo, AutoAttackRange))
        {
            print(rayInfo.collider.gameObject + " | " + target.gameObject);
            string targetTag = target.tag;
            if(target == rayInfo.collider.gameObject)
            {
                if (targetTag == "Destructable" || targetTag == "Player"
                    || targetTag == "Enemy")
                {
                    _isAttacking = true;
                    var v = GetComponent<NavMeshAgent>();
                    if (v.hasPath)
                    {
                        v.SetDestination(gameObject.transform.position);
                    }
                    if (!Network.isServer) CmdCall(target);
                    else RpcCall(target);
                }
            }
        }
    }
public virtual IEnumerator DeployMeleeRay ( GameObject target ) { yield return new WaitForSeconds ( 0.5f * GetComponent < Animator > ( ) . speed ) ; Vector3 forward = transform . TransformDirection ( Vector3 . forward ) ; Vector3 rayVector = transform . position + new Vector3 ( 0f , 2f , 0f ) ; Ray direction = new Ray ( rayVector , forward ) ; RaycastHit rayInfo ; if ( Physics . Raycast ( direction , out rayInfo , AutoAttackRange ) ) { print ( rayInfo . collider . gameObject + " " + target . gameObject ) ; string targetTag = target . tag ; if ( target == rayInfo . collider . gameObject ) { if ( targetTag == " " || targetTag == " " || targetTag == " " ) { _isAttacking = true ; var v = GetComponent < NavMeshAgent > ( ) ; if ( v . hasPath ) { v . SetDestination ( gameObject . transform . position ) ; } if ( ! Network . isServer ) CmdCall ( target ) ; else RpcCall ( target ) ; } } } }
Casts a ray to check for target
Casts a ray to check for target
// Wait for the animation to look as though it's attacking // The forward vector relative to the gameobject as opposed to the world // The position to fire from relative to the player //Debug.DrawRay(transform.position + new Vector3(0, 2f, 0), forward*_autoAttackRange, Color.green, 10); // Direction to fire the ray from // Information about the object hit with the ray cast
None
target
GameObject
None