public void rotateToFacePosition(Vector3 pos)
    {
        hc.rotateToFacePosition(pos);
        Vector3 rot = new Vector3(0, 0, Mathf.Atan2((pos.y - transform.position.y), pos.x - transform.position.x)) * Mathf.Rad2Deg;

        rot = new Vector3(rot.x, rot.y, rot.z - 90);                                                                   //add 90 to make the player face the right way (yaxis = up)
        //rid.transform.eulerAngles = rot;
        rid.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.Euler(rot), 5 * Time.deltaTime); // Quaternion.Euler(rot); //(INSTA ROTATION)

        //rotates player on Z axis to face cursor position
    }
Ejemplo n.º 2
0
    public void rotateToFacePosition(Vector3 pos)
    {
        if (this.gameObject.tag != "Player")
        {
            //if (this.GetComponent<NPCBehaviourDecider> ().myType == AIType.shopkeeper) {
            //	//Debug.Log ("SHOPKEEPER IS FACING " + pos.ToString ());
            //}

            if (pl == null)
            {
            }
            else
            {
                if (pos == null || pos == Vector3.zero || frozen == true || pl.waitingForPath == true)
                {
                    //if (this.GetComponent<NPCBehaviourDecider> ().myType == AIType.shopkeeper) {
                    ////Debug.Log ("SHOPKEEPER RETURNED NULL");
                    //}
                    return;
                }
            }
        }
        hc.rotateToFacePosition(pos);

        if (pl == null)
        {
            Vector3 rot = new Vector3(0, 0, Mathf.Atan2((pos.y - (transform.position.y)), pos.x - (transform.position.x))) * Mathf.Rad2Deg;
            rot = new Vector3(rot.x, rot.y, rot.z - 90);          //add 90 to make the player face the right way (yaxis = up)
            //rid.transform.eulerAngles = rot;
            rid.transform.rotation = Quaternion.Euler(rot);       //Quaternion.Slerp(this.transform.rotation,Quaternion.Euler(rot),getRotationSpeed()*Time.deltaTime);
        }
        else
        {
            if (pl.obstacle == true)
            {
                //if (this.GetComponent<NPCBehaviourDecider> ().myType == AIType.shopkeeper) {
                ////Debug.Log ("SHOPKEEPER RETURNED NULL 2");
                //}
                return;
            }
            else
            {
                Vector3 rot = new Vector3(0, 0, Mathf.Atan2((pos.y - (transform.position.y)), pos.x - (transform.position.x))) * Mathf.Rad2Deg;
                rot = new Vector3(rot.x, rot.y, rot.z - 90);              //add 90 to make the player face the right way (yaxis = up)
                rid.transform.rotation = Quaternion.Euler(rot);           //Quaternion.Slerp(this.transform.rotation,Quaternion.Euler(rot),getRotationSpeed()*Time.deltaTime);
            }
        }


        //rotates player on Z axis to face cursor position
    }