示例#1
0
    void Update()
    {
        this.pitchInput = Input.GetAxis("Mouse Y");
        float angularVelocity = this.transform.parent.GetComponent <PlayerController> ().angularVelocity;

        transform.rotation *= Quaternion.AngleAxis(pitchInput * Time.deltaTime * angularVelocity, Vector3.right);

        //target display
        Vector3i target = GetTarget(false);

        if (target != null)
        {
            this.debugObject.transform.position = target.Floatify();

            //TODO: OPTIMIZE!!!!
            Vector3i target2     = GetTarget(true);
            Vector3  finalTarget = target2.Subtract(target).Floatify();
            //this.debugObject.transform.rotation = Quaternion.LookRotation(finalTarget);
            //this.debugObject.transform.rotation = Quaternion.Euler(target.floatify());
            //Vector3 finalTarget2 = new Vector3(finalTarget.z, finalTarget.y, -finalTarget.x);
            //Vector3 finalTarget2 = new Vector3(0.2f, 0, 0);
            this.debugObject.transform.rotation = Quaternion.LookRotation(finalTarget);
            this.debugObject.SetActive(true);
        }
        else
        {
            this.debugObject.SetActive(false);
        }
    }