Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 CyberModeSoftware · Dec 29, 2020 at 10:14 PM · camera rotaterotatearound

Limit Rotate Around axis

I have big problems with limit axis on camera orbit with rotate around . What is happening?

  public float minimumX = -90F;
     public float maximumX = 90F;
     public float minimumY = -60F;
     public float maximumY = 60F;
     float rotationY = 0F;
     float rotationX = 0f;
 
     public GameObject cameraTarget1;
     public GameObject cameraTarget2;
     public GameObject cameraTarget3;
     public GameObject cameraTarget4;
 
     public bool cam2 = false;
     
     public float speed = 20f;
 
     public Vector3 dist;
     public Transform LookTarget;
     public Transform fpTarget;
     
     public Speedometer spedometer;
     public Shifter shift;
     public MoveCamera cameramove;
     
 
     private int currenttarget;
     private Transform cameratarget;
 
     public GameObject ScreenDash;
     public GameObject InteriorDash;
     public GameObject Character;
     public GameObject RearCamScreen;
     public GameObject ScreenNavi;
     
 
     public void Start()
     {
         currenttarget = 1;
         SetCameraTarget(currenttarget);
 
     }
 
     public void LateUpdate()
     {
         
 
         Vector3 dPos = cameratarget.position + dist;
         Vector3 sPos = Vector3.Lerp(transform.position, dPos, speed );
         
         transform.position = sPos;
         transform.LookAt(LookTarget);
        
 
         if (Input.GetMouseButton(0))
         {
 
             cameraTarget1.transform.RotateAround(LookTarget.transform.position, Vector3.up, rotationX);
             
             
 
 
         }
         
 
         if (cam2 == true)
         {
             transform.LookAt(fpTarget);
         }
         else if (cam2 == false)
         {
             transform.LookAt(LookTarget);
         }
     }
 
     public void SetCameraTarget(int num)
     {
 
         
 
         switch (num)
         {
             case 1:
                 cameratarget = cameraTarget1.transform;
                 cam2 = false;
                 ScreenDash.SetActive(enabled);
                 InteriorDash.SetActive(false);
                 Character.SetActive(true);
                 
 
                 break;
             case 2:
                 cameratarget = cameraTarget2.transform;
                 cam2 = true;
                 ScreenDash.SetActive(false);
                 InteriorDash.SetActive(enabled);
                 Character.SetActive(false);
                 
 
                 break;
             case 3:
                 cameratarget = cameraTarget3.transform;
                 cam2 = false;
                 ScreenDash.SetActive(enabled);
                 InteriorDash.SetActive(false);
                 Character.SetActive(true);
                 
                 break;
             case 4:
                 cameratarget = cameraTarget4.transform;
                 InteriorDash.SetActive(false);
                 cam2 = false;
                 Character.SetActive(true);
                 
 
                 break;
         }
     }
 
     private void RearScreenCam()
     {
         if (shift.reverse == true && cam2 == false)
         {
             ScreenNavi.SetActive(true);
             RearCamScreen.SetActive(true);
         }
 
         else if (shift.reverse == false && cam2 == false)
         {
             RearCamScreen.SetActive(false);
             ScreenNavi.SetActive(false);
         }
         
 
     }
   
 
     public void SwitchCamera()
     {
         if (currenttarget < 4)
         {
             currenttarget++;
         }
 
         else
             currenttarget = 1;
         SetCameraTarget(currenttarget);
     }
 
     private void FixedUpdate()
     {
         RearScreenCam();
     }
 
     
     void Update()
     {
         rotationX = Input.GetAxis("Mouse X");
         rotationX = Mathf.Clamp(rotationX,0,100);
         
         
 
     }
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

0 Replies

· Add your reply
  • Sort: 

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

155 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

Related Questions

Rotate camera around pivot not working on certain angles 0 Answers

Rotating Camera around Player's X-axis while rotating Player around its Y-axis (using mouse input) 0 Answers

How to use RotateAround with swipe gesture 0 Answers

Rotate Ball specific number of degrees and back again 0 Answers

How can I find the angle an object needs to turn towards a target from a rotated perspective? 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