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 Newunitydev11 · Aug 28, 2013 at 06:26 PM · rotaterotate objectx-axis

Translate to a distance then rotate and go back to earlier position on x-axis

I am considering a plane on which i have placed an image and I want this plane to move along x-axis.My problem here is that when i click on the plane it should move to a certain distance and then flip or rotate the plane and after the rotation it should move back to the original location.For example: If image is of a toy I want the toy to move 5 units to the left then the image of the toy should rotate to 180 and then again move back 5 units to right to its original position and this process should happen when i click on the plane/image.I am new to programming and also unity so i am clueless how should i do that?Any thoughts?Please let me know.

Comment
Add comment · Show 7
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 Newunitydev11 · Aug 29, 2013 at 08:26 AM 0
Share

can someone please guide me?? Is there any simpler way to do it????

 var moveforward;
 function Start(){
 moveforward = false;
 }
 function Update(){
 if(moveforward)
 forwardmovement();
  else if(!moveforward)
  backwardmovement();
  }
    function forwardmovement(){
    transform.position.x += 1 * Time.deltaTime;
    yield WaitForSeconds(1);
    moveforward = false;
    }
   function backwardmovement(){
   transform.position.x -= 1 * Time.deltaTime;;
   yield WaitForSeconds(1);
   moveforward = true;
    }

    this lets my image to move along x axis but after it reaches 1 unit i want it to rotate and then move -1 unit back to its original position.
avatar image robertbu · Aug 29, 2013 at 11:42 AM 0
Share

http://wiki.unity3d.com/index.php?title=$$anonymous$$oveObject

Also you can use iTween. It is free in the Asset store.

avatar image robertbu · Aug 29, 2013 at 11:45 AM 0
Share

I converted your 'Answer' to a comment. By adding follow-up information to your question as an answer, it made it appear that you question already had one answer...and therefore you would be less likely to get an answer.

avatar image fafase · Aug 29, 2013 at 01:14 PM 0
Share
  1. if not at target go to target

  2. if at target start rotation with coroutine

  3. while coroutine -> wait

  4. if coroutine over -> target = newTarget

  5. Back to 1

You have your two target in an array so that you can easily get from one to the other.

avatar image Newunitydev11 · Aug 29, 2013 at 01:54 PM 0
Share

But how should my code be like i am very new to program$$anonymous$$g and unity and I am understanding the logic but not exactly able to implement it.

Show more comments

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

16 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

Related Questions

Camera rotation around player while following. 6 Answers

How do I rotate an object in relation to the camera?,How do I rotate a sprite in relation to the camera? 2 Answers

Wonky Camera Behaviours 0 Answers

Rotate object 1 Answer

Have an object continuously rotate towards another 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