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
1
Question by smtabatabaie · Feb 20, 2013 at 05:34 PM · rotationeulerangleslocalrotation

Get the Inspector's rotation of an object with code

Hi , I have a character which in the start of the game changes its rotation with a lookAt and looks at a point . and when I see the inspector the rotations of my character are (0.66,135,0) . but when I try to debug.log my character's rotation I get (0,0,0) . I have tried :
transform.rotation
transform.localRotation
transform.eulerAngles
transform.localEulerAngles

and all of them return (0,0,0)
is there any method to return exactly what I see in the inspector?
thanks

Comment
Add comment · Show 5
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 PAEvenson · Feb 20, 2013 at 07:28 PM 0
Share

transform.localEulerAngles should give you what you see in the inspector. Im guessing you perhaps have the script on the wrong object?

avatar image smtabatabaie · Feb 20, 2013 at 08:48 PM 0
Share

yeah you're right , sorry I had attached it to another gameObject . but my problem still exists . my game is like this : my character changes its rotation with lookAt and then it's supposed to instantiate a bullet and shoot , but the bullet goes on the previous rotation of my character . and doesn't follow the rotation of lookAt .

avatar image smtabatabaie · Feb 20, 2013 at 09:14 PM 0
Share

I think it's Csharp , if i write it in javascript , the rotation changes with lookAt . I think I have to rewrite my scripts in javascript

avatar image robertbu · Feb 20, 2013 at 09:59 PM 0
Share

Your issue has nothing to do with C# or javascript. I suspect that you are not selecting the right object to use as a spawn point for the bullet, or you are using the wrong vector to apply the force. Typically I put an empty child object just in front of the gun as a spawn point. When you apply force, you can either use Rigidbody.AddForce(transform.forward), or you can use Rigidbody.ApplyRelativeForce(Vector3.forward).

avatar image smtabatabaie · Feb 21, 2013 at 06:28 PM 0
Share

Thanks , you're right it had nothing to do with C# or javascript (though I rewrote all of my scripts on javascript!) . it was the order of execution . I had several scripts which they referred to each other , i put the critical ones in one script and it worked! so far my experience in unity tells me to reduce the number of script as low as possible .

0 Replies

· Add your reply
  • Sort: 

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

Bike stay upright based on surface normal 1 Answer

Why is my object's local x rotation not going past 90 degrees? 1 Answer

Code to rotate around a local axis until local Y is 0? 0 Answers

Complicated Rotation Issue 1 Answer

how to apply overall rotation to collection of rotated objects 0 Answers


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