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 /
avatar image
0
Question by saifuzie · Apr 12, 2018 at 06:14 AM · 2d-platformerandroid buildcamera rotation

Camera Rotation Problem on Mobile

Hello everyone.

I make a 2d platformer game with Unity 2017.3, I have tested my game in my some android devices.

I have a problem when I try to rotate my camera on android. I have two cameras, Main camera is orthographic camera and another one is perspective camera. the perspective camera is a child of orthographic camera. alt text

There is no problem when I run my game in unity editor, but after I build on android, it suddenly stop when the rotation is called. The game doesn't crash or anything, it's just not responsive anymore. it is like a lag but it take a long time.

this is my rotation script

 public float time;
     bool isRotating = false;
 
     private float currentLerpTime;
     private float perc;
     Quaternion camTarget;
     //Animator anim;
 
     private void Start()
     {
         //anim = GetComponent<Animator>();
     }
 
     public void Rotate(bool right)
     {
         isRotating = true;
         currentLerpTime = 0;
 
         if (right == true)
         {
             //anim.SetBool("Right", true);
             //anim.SetBool("Left", false);
             camTarget = Quaternion.Euler(0, 0, 90);
             //transform.rotation = Quaternion.Slerp(transform.rotation, camTarget, 1);
 
         }
         else {
             //anim.SetBool("Right", false);
             //anim.SetBool("Left", true);
             camTarget = Quaternion.Euler(0, 0, 270);
             //transform.rotation = Quaternion.Slerp(transform.rotation, camTarget, 1);
 
         }
         StopCoroutine("Rotater");
         StartCoroutine("Rotater");
     }
 
     public void RotateBack()
     {
         isRotating = true;
         currentLerpTime = 0;
         camTarget = Quaternion.identity;
 
         //transform.rotation = Quaternion.Slerp(transform.rotation, camTarget, 1);
 
         //anim.SetBool("Right", false);
         //anim.SetBool("Left", false);
         StopCoroutine("Rotater");
         StartCoroutine("Rotater");
     }
 
     //private void Update()
     //{
     //    if (isRotating)
     //    {
     //        if (currentLerpTime > time)
     //        {
     //            currentLerpTime = time;
     //        }
     //        else
     //        {
     //            currentLerpTime += Time.deltaTime;
     //        }
     //        perc = currentLerpTime / time;
 
     //        transform.rotation = Quaternion.Slerp(transform.rotation, camTarget, perc);
 
     //        if (currentLerpTime >= time)
     //        {
     //            isRotating = false;
     //        }
     //    }
     //}
 
     IEnumerator Rotater()
     {
         while (true)
         {
             if (isRotating)
             {
                 if (currentLerpTime > time)
                 {
                     currentLerpTime = time;
                 }
                 else
                 {
                     currentLerpTime += Time.deltaTime;
                 }
                 perc = currentLerpTime / time;
 
                 //Vector3 rot = transform.eulerAngles;
                 //rot.z = Mathf.Lerp(rot.z, camTarget.eulerAngles.z, perc);
                 //if (rot.z < 0)
                 //    rot.z += 360;
                 //transform.eulerAngles = rot;
                 transform.rotation = Quaternion.Slerp(transform.rotation, camTarget, perc);
                 Debug.Log(transform.rotation.eulerAngles);
 
                 if (currentLerpTime >= time)
                 {
                     isRotating = false;
                 }
             }
             yield return null;
         }
     }

as you can see from script above. I have tried with the animation and update() as well. but result still same.

to make it more complicated, it is just happens in some area of the map. this is still prototype, so there is still not many things in the map.

alt text

capture.png (15.9 kB)
screenshot-4.png (162.3 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

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

82 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

Related Questions

So i need help with the gyroscope in an fps controller 0 Answers

2D platformer unity, respawn function not working in android build but works fine in editor,Respawn not working in Android build of @D unity platformer game 0 Answers

2D Ragdoll running game (Ragdoll Runners esk) 0 Answers

How to change the movement speed of a character 4 Answers

Acces PlatformerCharacter2D script 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