• 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 Xeong-Hu · Mar 27, 2014 at 02:21 AM · rotationtransform

How can i rotate an object at a certain point and stop

Hello all!

I want to rotate my object to a certain rotation and stop it.

For example. If I have a flat card facedown and when I want to reveal it. It'll rotate right up flipping it face up instead of being facedown.

I thought this would be fairly easy since I got my card to move.. But this isn't working with me and I'd really like it to.

So I tried it out and I got all sorts of crazy results.

Can someone please lend me a hand?

 selectedCard.transform.rotation.x += 24 * 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

1 Reply

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

Answer by hero_kenshin · Mar 27, 2014 at 03:26 AM

This can be achieved using quaternion.lerp https://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Lerp.html

It will rotate to a designated rotation Then you can have a separate one for rotation back

Comment
Add comment · Show 2 · 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 Xeong-Hu · Mar 27, 2014 at 05:08 AM 0
Share

Thanks a lot bro. I didn't think it was something like that. I actually like that style of doing it tbh. It's very visual, simple, and effective.

THA$$anonymous$$$$anonymous$$ YOU UNITY 3D!

avatar image Xeong-Hu · Mar 27, 2014 at 05:27 AM 0
Share

$$anonymous$$y Working Code.

For you other Unity People : )

     {
     
         
          selectedCard.transform.rotation =
           Quaternion.Lerp (from.rotation, to.rotation, Time.deltaTime * speed);
         selectedCard.transform.position = Vector3.$$anonymous$$oveTowards(selectedCard.transform.position, target1.position, step);
        {print("I have been Summoned!");}
        Screen.lockCursor = true;
     }
 
 }
 
 function OnGUI() {
     var e = Event.current;
  
     var x = pos.x - 50;  // Calc x and y to center of button
     var y = pos.y - 10;
 
     if (showButton && GUI.Button (Rect (x,y - 120, 100, 20), "Summon")) {
     print("Summoning");
         Summon = true;
         showButton = false;
         rotating = true;
     }
 }
  
 function CheckClick() {
 
     var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, hit)) {
     Debug.Log("Card selected:"+hit.collider.name);
            if (hit.collider.tag == "Card"){
                      inHand = true;
                     selectedCard = hit.collider.gameObject; //Store my selection
                     from = selectedCard.transform;
            }

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Trying to rotate weapon 0 Answers

player rotation to follow the mouse 2 Answers

Following another object's position/rotation like parent/child relationship? 4 Answers

Smooth Rotation Help 1 Answer

How do I align my player transform to waypoints and without restricting Z Axis rotation? 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