コード例 #1
0
ファイル: FiniteStateAI1.cs プロジェクト: iAmAim/Immutable
    public void Chase()
    {
        directionheading   = Target.transform.position - transform.position;
        directionheading.y = 0;

        /*if (direction.magnitude < 0.1)
         * return;*/
        // Rotate towards the target
        thisTransform.rotation    = Quaternion.Slerp(thisTransform.rotation, Quaternion.LookRotation(directionheading), rotationspeed * Time.deltaTime);
        thisTransform.eulerAngles = new Vector3(0, thisTransform.eulerAngles.y, 0);


        // move = thisTransform.TransformDirection(Vector3.forward);
        // myTransform.position = new Vector3(0,10,0);
        // control.Move(move * walkSpeed * Time.deltaTime);


        ////// test distance..
        float ourdistance = Vector3.Distance(Target.transform.position, thisTransform.position);

        // attack player if distance is close enough
        if (ourdistance <= attackrange)
        {
            //attack(); I used jumping for now.
            //jumping = true;
            // GameHud.playerhealth--;
            UnitPlayer.takeDamage();
            //Debug.Log("I bite you. :p");
            Debug.Log("Distance :" + distanceToPlayer);
        }
    }