예제 #1
0
    private void Attack()
    {
        Rigidbody rigi      = GetComponent <Rigidbody>();
        Vector3   targetDir = (target.position - transform.position).normalized;

        targetDir            = new Vector3(targetDir.x, 0, targetDir.z).normalized;
        transform.localScale = scaleOnAtack;
        transform.forward    = targetDir;
        rigi.AddForce(targetDir * attackSpeed, ForceMode.Impulse);
        currentState = SurroundingBallState.Attacking;
        //transform.position += targetDir * attackSpeed * Time.deltaTime;
    }
예제 #2
0
    protected override void Update()
    {
        base.Update();
        switch (currentState)
        {
        case SurroundingBallState.Idle:
            SurroundingMovement();
            if (IsEnemyOnRange())
            {
                if (IsClearAttack())
                {
                    currentState = SurroundingBallState.Attack;
                }
            }
            break;

        case SurroundingBallState.Attack:
            Attack();
            break;

        default:
            break;
        }
    }
예제 #3
0
 protected override void Awake()
 {
     base.Awake();
     currentState        = SurroundingBallState.Idle;
     rotateSelfDirection = new Vector3(UnityEngine.Random.Range(0, 9), UnityEngine.Random.Range(0, 9), UnityEngine.Random.Range(0, 9)).normalized;
 }