Exemple #1
0
    private void SwitchCameras()
    {
        //instantiate a new camera at the position of the object that was clicked on
        Become clickedObject = Instantiate(this, hit.collider.gameObject.transform.position, Quaternion.identity);

        clickedObject.gameObject.name = "Camera_Become";

        //Set the new object to ActivePlayer tag
        hit.collider.transform.gameObject.tag = "ActivePlayer";
        //The other object loses its ActivePlayer tag
        gameObject.transform.parent.tag = "Player";

        //make the camera a chid of the clicked game object and center its position relative to the player
        clickedObject.transform.SetParent(hit.collider.gameObject.transform);
        clickedObject.transform.position = hit.collider.transform.gameObject.transform.position;
        if (hit.collider.transform.gameObject.name == "boat")
        {
            clickedObject.transform.position     += new Vector3(0, 5, 10);
            clickedObject.transform.localRotation = Quaternion.Euler(20, 180, 0);
            //print(clickedObject.transform.position);
        }

        else
        {
            //clickedObject.transform.position -= new Vector3( 0, 5, 10);
            clickedObject.transform.localRotation = Quaternion.Euler(0, 0, 0);
        }

        //Destroy the old camera.
        Destroy(gameObject);
    }
    private void SwitchCameras()
    {
        //instantiate a new camera at the position of the object that was clicked on
        Become clickedObject = Instantiate(this, hit.collider.gameObject.transform.position, Quaternion.identity);

        clickedObject.gameObject.name = "Camera_Become";

        //make the camera a chid of the clicked game object and center its position relative to the player
        clickedObject.transform.SetParent(hit.collider.gameObject.transform);
        clickedObject.transform.localRotation = Quaternion.Euler(0, 0, 0);

        //Destroy the old camera.
        Destroy(gameObject);
    }
Exemple #3
0
    public void Rotate()
    {
        rotateYAxis += 3 * Input.GetAxis("Mouse X");
        rotateXAxis += 3 * Input.GetAxis("Mouse Y");

        characterBod.transform.rotation = Quaternion.Euler(0, rotateYAxis, 0);

        Become cam = GameObject.Find("Camera_Become").GetComponent <Become>();

        if (cam.GetCamMode() == 1)
        {
            cam.gameObject.transform.rotation = Quaternion.Euler(rotateXAxis, rotateYAxis, 0);
        }
        else
        {
            cam.gameObject.transform.rotation = Quaternion.Euler(33 + rotateXAxis, rotateYAxis, 0);
        }
    }
    private void SwitchCameras()
    {
        //instantiate a new camera at the position of the object that was clicked on
        Become clickedObject = Instantiate(this, hit.collider.gameObject.transform.position, Quaternion.identity);

        clickedObject.gameObject.name = "Camera_Become";

        //make the camera a chid of the clicked game object and center its position relative to the player
        clickedObject.transform.SetParent(hit.collider.gameObject.transform);
        clickedObject.transform.localRotation = Quaternion.Euler(0, 0, 0);


        //enable and disable the LocomotionUserControl - enable on one player at a time
        if (hit.collider.gameObject.GetComponentInParent <LocomotionController>() != null)
        {
            GetComponentInParent <LocomotionController>().enabled = false;
            hit.collider.gameObject.GetComponentInParent <LocomotionController>().enabled = true;
        }

        //Destroy the old camera.
        Destroy(gameObject);
    }