Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 tunerakos · Sep 26, 2016 at 07:42 PM · unity 2drotate object

Rotate Object 2 times for each rotation of other object

Hello guys.

I have 2 objects. When i rotate the first one 360 degrees for example i need to rotate the other 2 times that amount -> 720 degrees.

I also want to be able to rotate the second object counterclowise when the first rotates clockwise.

Assuming the rotator is the object that i rotate 360 degrees and the script is attached to the object i need to rotate twice as much here is the wrong code i wrote

         transform.Rotate ( Vector3.forward * rotationMultiplier * rotator.rotation.z);

The rotationMultiplier is 2 for this situation, but i also need to be able to use negative multiplier

Thanks in advance.

Comment
Add comment · Show 1
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 Sergio7888 · Sep 26, 2016 at 08:21 PM 0
Share

Any problem using a negative number? have you tried with negative numbers?

2 Replies

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

Answer by Sergio7888 · Sep 28, 2016 at 04:21 AM

Try this:


Vector3 originalRotation=transform.rotation.eulerAngles;
transform.rotation= Quaternion.Euler(originalRotation.x,originalRotation.y,rotator.rotation.eulerAngles.z * 2);
Also don't use rotation.z, rotation.z is Quarternion z value not the z angle to get the z angle use rotation.eulerAngles.z
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 tunerakos · Sep 28, 2016 at 06:25 PM 0
Share

Thank you very much. Working Great!!

(Such a pitty i don't have any remaining points to reward you...)

avatar image
0

Answer by tunerakos · Sep 27, 2016 at 06:25 AM

(i cant add comment so i have to post answer to Sergio7888 comment)

There isn't a problem using negative numbers. The object2 rotates to the opposite direction from the object1 when using negative numbers

The problem is that object2 doesn't get the rotation of the 1st object multiplied by the number but it continues to rotate since it is used in an Update function.

This is obvious since i used the transform.Rotate and not the transform.rotation that i am supposed to use. The problem with the transform.rotation is that i have to use the Quaternion and i don't know how to multiply it by the rotationMultiplier.

P.S. i need to rotate over z axis only. The x and y axis must stay untouched.

Thanks for your time and help.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Bullet dissapears from screen when I use LookAt? 0 Answers

How do I rotate a bullet (arrow) in Unity 2D? 0 Answers

What Should i use rigidbody.AddTorque() or Quaternions ? 1 Answer

Rotate object after swipe according to swipe direction 0 Answers

(2D) rotate object to face movement direction 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