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 oinkoinkflapflap · Jun 25, 2013 at 10:14 AM · rotationaxisfreezefixed

fixing rotation on a specific axis

I found this script on a forum for almost what i was looking for:

 var X_RotationLockedAt : int ; //locking the rotation at a certain angle for X
 var Y_RotationLockedAt : int ; //locking the rotation at a certain angle for Y
 var Z_RotationLockedAt : int ; //locking the rotation at a certain angle for Z
 
 function FixedUpdate(){
      transform.rotation = Quaternion.Euler(X_RotationLockedAt, Y_RotationLockedAt, Z_RotationLockedAt);
 }

But how do i get it to only freeze on one axis for example freeze on the Y axis but move with the parent object on X and Z, i tried

  transform.rotation = Quaternion.Euler.Y = Y_RotationLockedAt;

But it didn't work... no errors just didn't work!

Thanks in advance!

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

Answer by hirenkacha · Jun 25, 2013 at 10:39 AM

Try using this

 transform.eulerAngles = Vector3(0, Y_RotationLockedAt, 0); //check : Y_RotationLockedAt is in Euler

I used for C#

 transform.eulerAngles = new Vector3(0f,Y_RotationLockedAt,0f); 
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 oinkoinkflapflap · Jun 25, 2013 at 06:21 PM 0
Share

what do you mean by 'check : Y_RotationLockedAt is in Euler?' i've tried transform.eulerAngles = Vector3(X_RotationLockedAt, 0, Z_RotationLockedAt); as i want to freeze it in all but Y, it must be because it's still set to 0 on all 3... how can i make a var = to a Transform variable's Y rotation, so that i could set the Y value to this number var and make the number var be = to the parent's Y rotation (parent = Transform var)

for example:

var Parent : Transform; var ParentYvalue = 0;

ParentYvalue = to the Y rotation (this is what i don't know how to do)

transform.eulerAngles = Vector3(0, ParentYvalue, 0);

so that when the parent moves, it matches the Y yet the others are still 0 so only the Y moves... but how do i make a float variable = to a Transform variable's Y rotation... thanks look forward to your reply

avatar image hirenkacha · Jun 26, 2013 at 05:17 AM 1
Share

You can have y rotation in eulers of a parent using this

ParentYvalue = Parent.eulerAngles.y;

then use that in the object which you want to rotate.

 transform.eulerAngles = Vector3(0, ParentYvalue , 0); 

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

Player moving/rotating along a single axis 1 Answer

Camera rotation around a single axis - following a rolling ball 3 Answers

Freeze an Axis Rotation Help? 0 Answers

Freeze specific rotation axis of a child 2 Answers

Spinning a sphere, like a globe. 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