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 t-pedrob · Mar 18, 2013 at 08:53 PM · rotationrotatetranslatetranslation

Translate and rotate at the sametime problem

alt text

hi guys, i have a problem, i need to translate and rotate a plane at the sametime, but when i do that he change the direction and i want to go forward on the same direction (3)

1- A simple translate

2- A translate and rotate, but the direction change ;( (my current problem)

3- I want that the plane rotate 30º and hold the translation.

please, any help?!

sem título.png (6.7 kB)
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 robertbu · Mar 18, 2013 at 09:49 PM

Without seeing 1) your code, and 2) understanding the nature of the object (i.e. what position is the pivot the object rotates around), it hard to give you a definitive answer. There are a couple of things that can cause what you are seeing.

I'm going to assume that the point of rotation is in the center of the line. I'm also going to assume you are translating your object by using transform.forward for the direction. If so, the easiest fix is to use an empty game object as the parent, and the 'line' object as a child. To rotate the 'line' child, just use Transform.localRotation. The parent forward will still be in the correct direction, so the translation code uses the empty game object for its direction and position. If my assumptions here are not correct, please add more information.

Comment
Add comment · Show 5 · 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 t-pedrob · Mar 19, 2013 at 05:45 PM 0
Share

your assumptions were correct i have a empty parent gameobject that make a translation and a child that make a rotation.

Parent code when pressed:

transform.Translate(new Vector3(0,0,constantSpeed*Time.deltaTime*$$anonymous$$Speed));

child code when pressed:

transform.localRotation = Quaternion.Euler(new Vector3(0, 20, 0));

but don't work, when i press to go forward the gameobject as a whole, change the direction.

avatar image whydoidoit · Mar 19, 2013 at 05:46 PM 0
Share

I''ve converted your answer to a comment - on UA answer means solution and not reply. There's a "comment" button hidden at the right hand side.

avatar image t-pedrob · Mar 19, 2013 at 06:13 PM 0
Share

Hi, i already solved the problem, you were right! the reason of the strange behaviour was an other thing, i am very thankful to you. :)

avatar image robertbu · Mar 19, 2013 at 06:13 PM 0
Share

I'm confused. Is the behavior you want #2 above or #3 above? The code above does #3 which is what I thought you wanted. If it is #2, it is easy enough.

avatar image t-pedrob · Mar 19, 2013 at 06:20 PM 0
Share

No you were totally right, the code that i wanted was to make the #3 behavior, and with localRotation, it worked just fine, thanks!

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

11 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

Related Questions

Trouble rotating a prefab while it's moving up,Rotating an object with an animation while it moves up 0 Answers

Camera transform not responding after load 0 Answers

How to rotate the camera around an object 2 Answers

How do I translate my ship left and right and have it rotate at the same time? 1 Answer

Make an object translate/raycast a certain way disregarding it's rotation 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