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 Josh1231 · Jul 28, 2013 at 12:27 AM · c#rotate

C# how to rotate an object back to its original rotation

I've been trying this but it never works, it just stays how it is and it doesn't give me an error code. the if statement for this is:

 if (transform.rotation.z > 160f && transform.rotation.z < 200f)
     {
         
     }

it is supposed to be between 160 and 200 but i think i might have done the if statement wrong

Comment
Add comment · Show 6
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 cdrandin · Jul 28, 2013 at 12:34 AM 0
Share

Start by exa$$anonymous$$ing the behavior of those values. Just display them in the console and see what numbers you are getting and from there what numbers are needed for the desire you want.

avatar image robertbu · Jul 28, 2013 at 12:36 AM 0
Share

Please post more of your script. Not sure what you are attempting with just this line.

avatar image Josh1231 · Jul 28, 2013 at 12:40 AM 0
Share

i put it in that and i won't display any values

avatar image Forsyth · Jul 28, 2013 at 12:42 AM 0
Share

What are you trying to achieve exactly?

One problem I can see is that you're using transform.rotation which is a Quaternion variable. You want to be using transform.eulerAngles which is a Vector3 and will allow you to clamp between 160 and 200 degrees.

Could you please give more detail and context on what you are trying to do?

avatar image Josh1231 · Jul 28, 2013 at 12:44 AM 0
Share

now it moves but doesn't return to 0

Show more comments

2 Replies

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

Answer by Josh1231 · Jul 28, 2013 at 01:21 AM

don't worry, i fixed it by doing transform.eulerAngles

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 RyanZimmerman87 · Jul 28, 2013 at 12:55 AM

I would try out using Quaternion.identity that resets the position the only question is will this be the position you want to use, if not than you could probably apply some instant rotation or transform.position so that it does work like how you want.

Comment
Add comment · Show 1 · 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 Josh1231 · Jul 28, 2013 at 01:02 AM 0
Share

it does the same thing

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

17 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

C# Rotate More than Two GameObjects 1 Answer

Rotate camera smoothly for particular position with single INPUT 0 Answers

Unity 3d(Space) Questions 1 Answer

Turning Spinners Based on an Integer 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