Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Rydrako · May 11, 2013 at 04:19 AM · rotationquaternioneulermathf.sin

Why is Quaternion.Eular only rotating in one direction? [Answered]

Oh hai! So I got this weird thing going on and what I'm trying to do is instantiate a particle system and use the Qauternion.Eular to rotate it smoothly back and forth in this part of my script:

 if(flamePlayer)
             {
                 if(addt)
                 {
                         t = Time.time + 4.0;
                         addt = false;
                 }
                 if(!addt && Time.time < t)
                 {
                     if(make)
                     {
                         flame = Instantiate(flameThrowerPrefab, spawn.transform.position, Quaternion.identity);
                         make = false;
                     }
                         flame.transform.localEulerAngles.y = transform.localEulerAngles.y;
                         flame.transform.localEulerAngles.x = -30;
                         flame.transform.rotation = Quaternion.Euler(-30,
                         Mathf.Sin(Time.realtimeSinceStartup * flameThrowerSpeed) * flameThrowerAngle,0);
                 }
                 if(!addt && Time.time > t)
                 {
                         Destroy(flame.gameObject);
                         addt = true;
                         atPlayer = false;
                         flamePlayer = false;
                         make = true;
                         move = true;
                 }
             }

It will create the object and rotate it but...it will only rotate it in one direction, as if the object's Y rotation is always at 0. I need the object's Y rotation as same as mine.

Comment
Add comment · Show 4
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 robertbu · May 11, 2013 at 05:24 AM 0
Share

I'm not what you are asking or trying to do here, but let me make a couple of observations. On line 15 and 16, you assign the localEulerAngles independently. The reference for eulerAngles warns against setting them independently and I'm sure that applies to localEulerAngles as well. If you want to set them, put all three values in a Vector3 and assign them all at once. Note line 15 (assigning the 'y' to itself) does nothing.

But the above issues are not relevant because you completely overwrite the rotation in line 17. This nulls the previous two lines. Line 17 also sets the rotation to an absolute rotation in world space which is unlikely what you want and the reason for the behavior you see. I need a better understand of your desired behavior before I could suggest a fix.

avatar image Rydrako · May 11, 2013 at 04:09 PM 0
Share

Okay so you read my question you get that it the flame faces only in one direction. Well I want the flame to face the direction my boss is facing and still be able to rotate. It's like when the boss is facing 180-ish degrees Y it looks fine but then he faces the opposite and it's behind him. I just want it to rotate and face the same direction as the boss...

avatar image robertbu · May 11, 2013 at 04:17 PM 0
Share

One easy way to solve this problem would be to use an empty game object. The empty game object would faces your target ('boss'). The physical game object would be a child object of the empty game object. You would use your $$anonymous$$athf.Sin() code above, but you would assign it to 'transform.localRotation' not 'transform.rotation'.

avatar image Rydrako · May 11, 2013 at 04:38 PM 0
Share

Thanks! I just attached the flame object to it since it was already an empty and changed it to localRotation!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by richardgengle · Aug 05, 2020 at 10:32 PM

@Rydrako ?try rotate towards?

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

14 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

Related Questions

Is there no way to get reliable angles from a rigidbody? 2 Answers

Rotation with a slider 2 Answers

How make child object rotate inverse to its parents rotation ? 1 Answer

apply a modified rotation based on another objects' rotation 1 Answer

help me to rotate an object 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