Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by karmoon5 · Jul 06, 2018 at 12:52 PM · cameracamera-movementcamera rotate

How to make one movement direction be equal to diferent cameras?

Hello,

I have 4 cameras, each camera represents a player, so, I have player one camera, player two camera, player three camera, and finaly, player four camera. All cameras are lookingAt() same target. I have a UI with two buttons, one to make camera RotateArround() the target, like in a orbit, but only moves in one direction, and the second button its to make camera RotateArround() the target and move it backwards to the initial position in the inverse direction.

What's the problem? The problem it's that I can rotate with player one camera arround the target but when I change to player two, three or four, the cameras start rotating in wrong directions. This is because every camera as its own rotation and position values, so moving a axis one camera brings diferents results in every camera.


Examples

Behaviours: alt text

Cameras Controll script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class cameraControll : MonoBehaviour
 {
 
     private GameObject lookAtTarget;
 
     private int speed = 0;
     
     private float zoomSmoothness = 0;
     private float minZoom = 0;
     private float maxZoom = 0;
 
     private float maxRotationX = 0;
     private float minRotationX = 0;
 
     public void moveUp()
     {
         if (lookAtTarget == null)
         {
             Debug.LogError("Camera target it's null");
             return;
         } 
 
         if (transform.rotation.x > maxRotationX)
         {
             return;
         }
 
         Debug.Log("Current position: " + transform.position + " Current rotation: " + transform.rotation);
         transform.RotateAround(lookAtTarget.transform.position, new Vector3(0, 0, transform.position.z + 1), Time.deltaTime * speed);
     }
 
     public void moveDown()
     {
         if (lookAtTarget == null)
         {
             Debug.LogError("Camera target it's null");
             return;
         }
 
         if (transform.rotation.x < minRotationX)
         {
             return;
         }
 
         transform.RotateAround(lookAtTarget.transform.position, Vector3.left, Time.deltaTime * speed);
     }
 
     public void zoomIn()
     {
         GetComponent<Camera>().fieldOfView = Mathf.Lerp(GetComponent<Camera>().fieldOfView, minZoom, Time.deltaTime * zoomSmoothness);
     }
 
     public void zoomOut()
     {
         GetComponent<Camera>().fieldOfView = Mathf.Lerp(GetComponent<Camera>().fieldOfView, maxZoom, Time.deltaTime * zoomSmoothness);
     }
 
     
     //Setters && Getters\\
 
     public void setLookAtTarget(GameObject lookAtTarget)
     {
         this.lookAtTarget = lookAtTarget;
     }
 
     public void setSpeed(int speed)
     {
         this.speed = speed;
     }
 
 
     public void setMinZoom(float minZoom)
     {
         this.minZoom = minZoom;
     }
 
     public void setMaxZoom(float maxZoom)
     {
         this.maxZoom = maxZoom;
     }
 
     public void setZoomSmoothness(float zoomSmoothness)
     {
         this.zoomSmoothness = zoomSmoothness;
     }
 
     public void setMaxRotationX(float maxRotationX)
     {
         this.maxRotationX = maxRotationX;
     }
 
     public void setMinRotationX(float minRotationX)
     {
         this.minRotationX = minRotationX;
     }
 }
 

Any solutions?

Thank you in advance.

example.png (18.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Adam_Myhill · Jul 06, 2018 at 09:07 PM

This is a fantastic question and I must ask a favour of you to please re-ask it on the Cinemachine forums. That's where we discuss everything CM.

Please ask again here: https://forum.unity.com/forums/cinemachine.136/

Thanks so much, Adam

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by karmoon5 · Jul 07, 2018 at 05:23 PM

For those with the same question, here is a link to the new thread: https://forum.unity.com/threads/how-to-make-one-movement-direction-be-equal-to-diferent-cameras.539452/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

205 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help With Camera rotation on X and Y Axis (Target Focused) 1 Answer

viewing on the Mouse Y axis not working. 0 Answers

Using DampSmooth in EulerAngle is affecting the Position.Z value of the gameObject. 0 Answers

How to recreate the Silent Hill 1 camera style? 0 Answers

Camera can't keep up with mouse when the FPS is low 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges