Пример #1
0
    // Use this for initialization
    void Awake()
    {
        ThisCamera = Camera.main.transform;
        ThisCamera.GetComponent <Camera>().fieldOfView = MaxFOV;
        TargetFOV    = MaxFOV;
        MousePosLast = Input.mousePosition;


        Target1 = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
        Target2 = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;

        //鍒涘缓鍙傝€冪墿浣搝z
        Target1.position = Vector3.zero;
        Target2.position = Vector3.zero;
        Target1.GetComponent <Renderer>().enabled = false;
        Target2.GetComponent <Renderer>().enabled = false;
        Target1.GetComponent <Collider>().enabled = false;
        Target2.GetComponent <Collider>().enabled = false;
        Target2.parent = Target1;

        Target1.localEulerAngles = new Vector3(0, BaseLookAt, 0);
        Target2.localEulerAngles = new Vector3(BaseAngles, 0, 0);

        //鍒涘缓鎽勫奖鏈鸿繍鍔ㄧ粨鏋剒z
        Parent1          = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
        Parent2          = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
        Parent1.position = Vector3.zero;
        Parent2.position = Vector3.zero;
        Parent1.GetComponent <Renderer>().enabled = false;
        Parent2.GetComponent <Renderer>().enabled = false;
        Parent1.GetComponent <Collider>().enabled = false;
        Parent2.GetComponent <Collider>().enabled = false;

        Parent2.parent    = Parent1;
        ThisCamera.parent = Parent2;

        //Parent1.localEulerAngles=new Vector3(0,BaseLookAt,0);
        Parent2.localEulerAngles    = new Vector3(BaseAngles, 0, 0);
        ThisCamera.localPosition    = new Vector3(0, 0, 0);
        ThisCamera.localEulerAngles = Vector3.zero;

        //
        Target1.position = BasePositton.position;
        Parent1.position = BasePositton.position;
        LastPosition     = Vector3.zero;
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        ThisCamera = Camera.main.transform;

        Parent1          = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
        Parent2          = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
        Parent1.position = Vector3.zero;
        Parent2.position = Vector3.zero;
        Parent1.GetComponent <Renderer>().enabled = false;
        Parent2.GetComponent <Renderer>().enabled = false;
        Parent1.GetComponent <Collider>().enabled = false;
        Parent2.GetComponent <Collider>().enabled = false;

        Parent2.parent    = Parent1;
        ThisCamera.parent = Parent2;

        Parent2.localEulerAngles    = new Vector3(45, 0, 0);
        ThisCamera.localPosition    = new Vector3(0, 0, -StartDistance);
        ThisCamera.localEulerAngles = Vector3.zero;

        MousePosLast = Input.mousePosition;
    }