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 /
avatar image
0
Question by Alayna · Apr 24, 2013 at 09:49 PM · camerarotationsmoothtiltturn

Bank Camera Based On Rotation Delta

Hello, I am trying to put together a simple banking effect when the camera turns left or right. The Camera is not able to look up or down, the only angle that changes is the y. I have tried using this to find the angle delta and apply it to the z axis;

 var mainCamera : GameObject;
 var lastCamRotation : float;
 var currentCamRotation : float;
 var angleDifference : float;
 var speedAdjust : float;
 
 function Start (){
      lastCamRotation = mainCamera.transform.localEulerAngles.y;
 }
 
 function Update (){
      currentCamRotation = mainCamera.transform.localEulerAngles.y;
      angleDifference = Mathf.DeltaAngle(currentCamRotation,lastCamRotation);
      lastCamRotation = currentCamRotation;
      mainCamera.transform.localEulerAngles.z = angleDifference*speedAdjust;
 }

Due to the method of moving being used on a touchscreen, I cannot use any getAxis functions or anything that is specific to mice. There are no errors with this script in the editor, the problem is that it is very rough input. Even when I had smoothed it it would vibrate wildly while turning left or right. Could anyone help me figure out how to make this script work smoothly or find a better way to simulate banking when turning left or right? Any help would be greatly appreciated!!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by LyanApps · Apr 25, 2013 at 03:07 AM

I would suggest: http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.RotateTowards.html

 //Save the current Rotation
 currentRotation = transform.localRotation;
 //Calculate the rotation you want to have
 targetRotation = Quaternion.Euler(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.y + angleDifference);
 //Use RotateTowards to find the in between rotations based on angular step
 transform.localRotation = Quaternion.RotateTowards(currentRotation, targetRotation, speed*Time.deltaTime);
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

12 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

Related Questions

Smooth camera rotation velocity. 0 Answers

Turning the camera down smoothly while running 2 Answers

Smooth tilting rotation on slopes like cars? 1 Answer

Slight Problem in the Camera Rotation Script 0 Answers

Rotate around object smoothly 1 Answer


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