示例#1
0
    void ChasePlayer()
    {
        orientation = (int)Mathf.Sign(playerTransform.position.x - thisTransform.position.x);
        aniPlay.PlayFramesFixedFPS(5, 5, 2, orientation, 1, 14);
        //aniPlay.PlayFrames(5, 5, 2, orientation, 14);

        //Vector3 Distance = playerTransform.position - thisTransform.position;
        Vector3 Distance   = playerTransform.position + (Vector3.up) - thisTransform.position;
        float Displacement = moveSpeed * Time.deltaTime;

        //thisTransform.position += Vector3.up * Mathf.Sin(Time.time * 3) * Time.deltaTime;


        thisTransform.position += (Distance.normalized * Displacement);
        thisTransform.position += (Vector3.up * Mathf.Sin(Time.time * 5) * Time.deltaTime);
    }
示例#2
0
    void Roam()
    {
        aniPlay.PlayFramesFixedFPS(5, 2, 2, orientation, 1, 5);

        RaycastHit hit;

        //Debug.DrawLine(thisTransform.position, thisTransform.TransformPoint(Vector3.right), Color.red);
        if (Physics.Linecast(thisTransform.position, thisTransform.TransformPoint(-Vector3.right), out hit) &&
            hit.collider.gameObject.tag == "Untagged" && hit.collider.gameObject.layer != 11)
        {
            orientation = 1;
        }

        //Debug.DrawLine(thisTransform.position, thisTransform.TransformPoint(Vector3.left), Color.red);
        if (Physics.Linecast(thisTransform.position, thisTransform.TransformPoint(Vector3.right), out hit) &&
            hit.collider.gameObject.tag == "Untagged" && hit.collider.gameObject.layer != 11)
        {
            orientation = -1;
        }

        if (OnWater)
        {
            velocity.x = 2 * orientation;
            velocity.y = Mathf.Sin(Time.time * 3) * .35f;
        }
        else
        {
            //Debug.DrawLine(thisTransform.TransformPoint(Vector3.down * .4f), thisTransform.TransformPoint(Vector3.down * .5f), Color.blue);
            if ((int)currentState < 3 &&
                Physics.Linecast(thisTransform.position, thisTransform.TransformPoint(Vector3.down * .5f), out hit) &&
                hit.collider.gameObject.tag == "Untagged" && hit.collider.gameObject.layer != 11)
            {
                velocity.y = 2;
            }

            velocity.x = 1 * orientation;
        }
    }