コード例 #1
0
    // Use this for initialization
    void Start()
    {
        //Je dit que je peut tourner la caméra
        timer = delayrotcam;

        //Je récupère le perso et le god
        Perso = GameObject.FindGameObjectWithTag("Player");
        God   = GameObject.FindGameObjectWithTag("God");

        //Récupérer le milieu et la taille depuis Cube_Creation
        largeur  = Mathf.RoundToInt(Perso.GetComponent <Cube_Rotations> ().GetCubeSize().x);
        hauteur  = Mathf.RoundToInt(Perso.GetComponent <Cube_Rotations> ().GetCubeSize().y);
        longueur = Mathf.RoundToInt(Perso.GetComponent <Cube_Rotations> ().GetCubeSize().z);

        //Creation du point central pour la caméra
        float milx = (float)(((float)largeur / 2) - 0.5F);
        float mily = (float)(((float)hauteur / 2) - 0.5F);
        float milz = (float)(((float)longueur / 2) - 0.5F);

        target = new Vector3(milx, mily, milz);

        //je définis la position de la caméra pour avoir le bon angle (qui fait des jeux de perspectives)
        poscam [0] = new Vector3(milx - 4F, mily + 4F, milz - 4F);
        poscam [1] = new Vector3(milx - 4F, mily + 4F, milz + 4F);
        poscam [2] = new Vector3(milx + 4F, mily + 4F, milz + 4F);
        poscam [3] = new Vector3(milx + 4F, mily + 4F, milz - 4F);

        //j'initialise la caméra
        cameraposprec      = poscam [GetCamNumber()];
        transform.position = poscam [GetCamNumber()];
        transform.LookAt(target);
    }
コード例 #2
0
    void GetInputRotation()
    {
        if (CanRotate)         //Si je permet à ma caméra de tourner
        {
            //jJe détermine à quel point est la caméra selon la rotation
            if ((timer >= delayrotcam) && (Input.GetButtonDown("CameraH")) && !Perso.GetComponent <Cube_Rotations> ().RotationReady() && (!Rot360))
            {
                timer     = 0;
                rotationH = true;

                if (Can360)                 //Si la caméra est faite pour faire des tours à 360 je fais des tours à 360
                {
                    Rot360 = true;
                }
                else
                {
                    ChangeCameraPos(1);
                }
            }

            if ((timer >= delayrotcam) && (Input.GetButtonDown("CameraAH")) && !Perso.GetComponent <Cube_Rotations> ().RotationReady() && (!Rot360))
            {
                timer      = 0;
                rotationAH = true;

                if (Can360)                 //Si la caméra est faite pour faire des tours à 360 je fais des tours à 360
                {
                    Rot360 = true;
                }
                else
                {
                    ChangeCameraPos(-1);
                }
            }
        }
        else if (Input.GetButtonDown("CameraH") || Input.GetButtonDown("CameraAH"))           //Si j'interdis la rotation de la caméra mais que le joueur essaye de la tourner
        {
            GameObject.Find("No_Camera").GetComponent <CanvasRenderer> ().SetAlpha(1f);       //J'affiche rapidement l'icône d'interdiction de rotation de la caméra
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        //J'incrémente le timer
        MyTimer();

        if (Perso.GetComponent <Can_Act> ().canact)        //J'attends que l'UI de fade soit passé pour permettre au joueur de faire des trucs
        {
            //Je récupère les inputs du joueur
            ChangeVue();
            GetInputRotation();
        }

        //J'adapte la caméra à la situation actuelle
        OrthoSize();
        CameraLookAt();
        Turn360();
        if (!Rot360)
        {
            CameraPos();
        }

        //Je sauvegarde l'ancienne position de la caméra
        SaveCameraPosPrec();
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        //je récupère la position du perso
        persox = Perso.position.x;
        persoy = Perso.position.y;
        persoz = Perso.position.z;

        //je récupère l'état du perso
        saut = Perso.GetComponent <Controle_Personnage> ().ensaut;

        //je regarde si le joueur bouge après le plan compensé
        if ((Input.anyKeyDown) & (fineffetdramatique))
        {
            abouge = true;
        }

        //caractéristiques caméra fonction marche sur laquelle est le personnage avant l'effet dramamtique
        if ((persox <= 5.9F) & (!effetdramatique) & (!fineffetdramatique))
        {
            Quaternion targetRotation = Quaternion.LookRotation(Planete.transform.position - transform.position);

            // Smoothly rotate towards the target point.
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime);
            transform.position = new Vector3(persox - 2F - (2.7F * 0.1666666F * (persoy + 0.1F)), persoy + 0.9F + (0.1F * (persoy + 0.1F)), persoz);
        }

        //caractéristiques caméra fonction marche sur laquelle est le personnage après l'effet dramamtique
        if ((persox > 6.9F) & (!effetdramatique) & (fineffetdramatique) & (abouge))
        {
            Quaternion targetRotation = Quaternion.LookRotation(Perso.transform.position - transform.position);

            // Smoothly rotate towards the target point.
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime);

            positionposteffet  = new Vector3(persox - 21.1F + (2.8225F * (persox - 5.9F)), persoy + 12.25F + (-0.2666666F * (persoy - 5.9F)), persoz);
            transform.position = Vector3.Lerp(transform.position, positionposteffet, smoothTimeregard * Time.deltaTime);
        }

        //caractéristiques caméra fonction marche sur laquelle est le personnage après l'effet dramamtique
        if ((persox >= 5.9) & (persox < 6.9F) & (!effetdramatique) & (fineffetdramatique) & (abouge))
        {
            Quaternion targetRotation = Quaternion.LookRotation(Planete.transform.position - transform.position);

            // Smoothly rotate towards the target point.
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime);

            positionposteffet  = new Vector3(persox - 21.1F + (2.8225F * (persox - 5.9F)), persoy + 0.9F + (0.1F * (persoy + 0.1F)), persoz);
            transform.position = Vector3.Lerp(transform.position, positionposteffet, smoothTimeregard * Time.deltaTime);
        }

        //caractéristiques caméra fonction marche sur laquelle est le personnage avant l'effet dramamtique
        if ((persox < 5.9F) & (!effetdramatique) & (fineffetdramatique) & (abouge))
        {
            Quaternion targetRotation = Quaternion.LookRotation(Perso.transform.position - transform.position);

            // Smoothly rotate towards the target point.
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smoothTimeregard * Time.deltaTime);
            positionposteffet  = new Vector3(persox - 2F - (4.7F * (persoy + 0.1F)), persoy + 0.9F + (2F * (persoy + 0.1F)), persoz);
            transform.position = Vector3.Lerp(transform.position, positionposteffet, smoothTimeregard * Time.deltaTime);
        }

        //je fais le plan compensé au sommet de l'escalier
        if ((Mathf.RoundToInt(persoy) == 6) & (!saut) & (!fineffetdramatique))
        {
            effetdramatique         = true;
            Camera.main.fieldOfView = Camera.main.fieldOfView - smoothTimeeffet * Time.deltaTime;
            camerapanx         = (35.35F * ((Camera.main.fieldOfView - 12.06F) / (Camera.main.fieldOfView + 1.072F))) - 28.52F;
            camerapany         = (-0.0133F * Camera.main.fieldOfView) + 8.4145F;
            transform.position = new Vector3(camerapanx, camerapany, transform.position.z);
        }

        if (Camera.main.fieldOfView - 20F <= 0)
        {
            Camera.main.fieldOfView = 20F;
            fineffetdramatique      = true;
            effetdramatique         = false;
        }
    }