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 Waffle Dragon · Apr 30, 2014 at 02:35 AM · rotationrotatemax

Min, Max Rotation Help

Im trying to set the Min and max rotation for my camera, this my attempt.

 void Update() {
     //X Rotation Min and Max
     if (transform.eulerAngles.x >= -15){
         transform.eulerAngles.x = -15;
     }        
     if (transform.eulerAngles.x <= -60){
         transform.eulerAngles.x = -60;
     }

and this is were the rotation is happening

 _currentCameraRotation.x += changeInRotationX * settings.rotation.cameraRotationRate.x * Time.deltaTime;
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 MikeNewall · Apr 30, 2014 at 02:45 AM

You didn't state what was wrong in your question...

You can't modify the rotation components like that. Store the rotation in a local variable, clamp the values, and then reassign the objects rotation.

Comment
Add comment · Show 4 · 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 MikeNewall · Apr 30, 2014 at 03:34 AM 0
Share

You can limit the value of a float between a $$anonymous$$ and max value using $$anonymous$$athf.Clamp:

   //Get the current rotation
     Vector3 clampedRotation = transform.eulerAngles;
     // Clamp the X value
     clampedRotation.x = $$anonymous$$athf.Clamp(clampedRotation.x, -60, -15);
     // assign the clamped rotation
     transform.rotation = Quaternion.Euler(clampedRotation);
avatar image Waffle Dragon · Apr 30, 2014 at 03:48 AM 0
Share

I added this code to the update function but it doesn't seem to work?

avatar image MikeNewall · Apr 30, 2014 at 03:55 AM 0
Share

"This is where the rotation is happening" You're just assigning the x component of a variable(Vector3), there is no rotation happening unless you're trying to assign that variable to the rotation some place else?.

Where are you getting the variable "changeInRotationX" from and how are you calculating it?

Is this done in a single script? And is it attached to your camera?

It's easier to help if you explain things a little better :p

avatar image Waffle Dragon · Apr 30, 2014 at 04:02 AM 0
Share

Its okay Iv figured it out now, thanks for the help.

avatar image
0

Answer by conceptfac · Oct 17, 2020 at 10:50 PM

Here shakes only when i rotate x axis for down! RIDICULOUS!

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

22 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

Related Questions

Multiple Cars not working 1 Answer

How can i make my aircraft rotate as smooth as the one in race the sun, and then go back to its original position 1 Answer

Viewmodel/camera rotation when moving 1 Answer

How can i limit rotation in my script? 0 Answers

how to tilt boat on turning 2 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