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 Doggi · Apr 16, 2014 at 03:34 AM · rotationmouseclick

transition.rotation not working.

Here is my script (the variable will come in to play as I develop more).

 #pragma strict
 var a;
 function OnMouseDown() {
     transform.position.x=613;
     transform.position.y=18.07;
     transform.position.z=583;
     transform.rotation.x=359;
     transform.rotation.y=283;
     transform.rotation.z=364;
     var a = 0;
 }

In game, I press on the game object and the positioning is perfect, but the rotation is not working. I keep on adjusting the values, but nothing happens.

The fixed values are: 359.6852 = X, 0.001112414 = y, and 180 = z

The object keeps appearing straight upside-down (but is not quite).

Please help, thanks and 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
0

Answer by robertbu · Apr 16, 2014 at 03:36 AM

A Transofrm.rotation is a Quaternion...a 4D, non-intuitive construct. The x,y,z, and w components are not angles and have a value between -1 and 1. For what you are doing, you can use transform.eulerAngles, but you will get undesirable results if you attempt to set them independently. Instead you should set them all at once like:

  transform.eulerAngles = Vector3(359.0, 283.0, 364.0);
Comment
Add comment · Show 4 · 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 Doggi · Apr 17, 2014 at 02:35 AM 0
Share

THAN$$anonymous$$ YOU

avatar image Doggi · Apr 17, 2014 at 03:19 AM 0
Share

There's another problem (I know).

 #pragma strict
 var a;
 function On$$anonymous$$ouseDown() {
         transform.position.x=613;
         transform.position.y=19;
         transform.position.z=583;
         transform.rotation.eulerAngles = Vector3(-27.0, -74.0, 0);    
         a=0;
 }
 
 function OnGUI() {
     if (a == 0) {
         GUI.Box(Rect(100,100,200,100), "This was brought \ninto your inventory.");`
     }
 }

The console says "interact.js(13,91): BCE0044: unexpected char: '`'.".

Please help.

avatar image robertbu · Apr 17, 2014 at 03:31 AM 0
Share

You have a back-tick character appended to line 13. Delete the last character on the line, and your code will compile.

avatar image Doggi · Apr 18, 2014 at 09:05 PM 0
Share

Anyway, i deleted it and did it again (just line 13). Works 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

20 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

Related Questions

Trying to make rotation stay in top down 2D on mouse button release 0 Answers

Rotate UI Image cirlce around self OnMouseclick 1 Answer

Need to rotate an object towards mouse click 1 Answer

How do you make a gameobject rotate slowly to the direction of the mouseclick 0 Answers

Rotate gameobject to face mouse click over time 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