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 knuckles209cp · Apr 25, 2019 at 04:34 AM · rotationjavascripttransform

Rotation not going past 180?

My player wont pass 180 degrees ( clockwise or anti clock wise ), It slows down more and more the closer it gets to 180. if(Input.GetAxis("Horizontal")){ transform.localRotation.y += Time.deltaTime * TurnSpeed;

                         }


Thanks

Comment
Add comment · Show 2
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 KevRev · Apr 25, 2019 at 09:12 AM 0
Share

Rotation is from -180 to +180.

avatar image knuckles209cp KevRev · Apr 25, 2019 at 09:14 AM 0
Share

How would i keep going past 180? Thanks for reply.

2 Replies

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

Answer by Bunny83 · Apr 25, 2019 at 09:24 AM

Your script can not work because it has multiple issues:


First of all the most important. localRotation as well as rotation are unit Quaternions, not euler angles. Quaternions are an expansion of complex numbers. The 4 values (x,y,z,w) are in the range -1 to 1 and do not resemble euler angles (3 consecutive rotations around 3 seperate principal axes). Quaternions have many advantages as they do not suffer from Gimbal lock like euler angles. However Quaternions are less intuitive. It actually represents a single 3d rotation axis as well as an angle (not in degree or radians) around that axis.


Second this statement:

  transform.localRotation.y += xxx;

doesn't have any effect on the actual rotation since localRotation is a property of a struct. This line does not invoke the setter of the property and therefore does not change the value at all. Note that this line did work in UnityScript. However UnityScript (Unity's Javascript like language) is already deprecated for quite some time now.


Finally keep in mind that even when the rotation part would work, adding constantly to the rotation would rotate your player endlessly.


If you want actual help with your actual problem, it would help when you describe what you actually want to achieve. To actually rotate an object around the y axis in degree you can use transform.Rotate(0, amount, 0);


If you actually want to learn more about quaternions I recommend this Numberphile video on quaternions as a brief introduction. And if you have the time watch the 3b1b series on quaterions


ps: I just noticed you added the "javascript" tag. Does that mean you still use UnityScript? I would highly recommend to switch to C#. The latest Unity versions do not support UnityScript anymore.

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 knuckles209cp · Apr 25, 2019 at 10:15 AM 0
Share

Hi, thanks for the answer! transform.Rotate works perfectly. I will definitly use C#, I had no idea about the removal of java.

avatar image
0

Answer by K-Anator · Apr 25, 2019 at 05:33 AM

I'm having a hard time figuring out how you're even rotating the character with the given script. From what I can gather, you're just moving them to the right when the player presses down. What style of game is this? Top down? Side scroller? 2D? 3D?

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 knuckles209cp · Apr 25, 2019 at 05:58 AM 0
Share

Its a 3d snowboarding game, when he goes left or right he should be able to corner constantly but it just slows down the cornering

avatar image knuckles209cp · Apr 25, 2019 at 08:36 AM 0
Share

Updated the script, posted the wrong one sorry

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

207 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 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 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 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 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 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 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 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 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 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

Smooth Rotation Help 1 Answer

transform.LookAt overrides rigidbody rotation 0 Answers

How to add random force/Rotation to bulletEject. 1 Answer

Finish a rotation with cube face up. 1 Answer

Make camera 1 transform equal to camera 2 transform 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