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 Gun_Asylem · Mar 25, 2014 at 06:54 PM · 2drotateaxisshootflip

Flipped objects Rotation issues

So i have a 2d Character Sprite and standard Movement code that Flips the XScale when moving left.

Then i have a Child Object named(RotToPos) which has a Rotationscript in it that traces to where the mouse is.

Then there is a Child Object of that which Contains (ShootFrom) its used to Fire the projectile from the End of the barrel.

Everything works fine untill you move left and the XScale changes, then everything gets Wonky... Actually its easier if you see it for yourself. Link to Downloadable File

and yes, i know i didnt fix the Flips Rotation but even when i do it still gets wonky Script on the RotToPos**

     void Update () {
         Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
         Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
         lookPos = lookPos - transform.position;//transform.position-lookPos;//lookPos - transform.position;
         float angle = (Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg);
         //if(angle > 90 || angle < -90)
         //    angle = Mathf.Sign(angle) * 180 - angle;
         print ((angle));//-180)*-1);
         transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
 

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 joshpsawyer · Mar 28, 2014 at 08:12 PM

When you flip localScale.x of your sprite, you're flipping it for all its children as well. If you're facing left, and you move the mouse ~45 degrees off the ground to the right of the character, the gun will aim 45 degrees off the ground in the left direction.

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 Gun_Asylem · Mar 30, 2014 at 03:16 AM 0
Share

I Understand that, but for some reason, when facing Left, the CHildren of the Gun Rotate on their Own when $$anonymous$$oving the $$anonymous$$ouse, Ins$$anonymous$$d of Being Fixed to the Gun like when facing Right.

avatar image joshpsawyer · Mar 30, 2014 at 05:10 PM 0
Share

If you fix the aforementioned problem, does it still happen? Without seeing the relevant code and their initial transforms, it's not easy to diagnose.

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

21 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

Related Questions

Rotating an object on Z axis while moving 1 Answer

How to lock the Z axis so my Enemy just flips on the Y axis 1 Answer

How can I make my Enemy look/flip towards my player (2D TOP-DOWN) 1 Answer

problem with rotation 2D 1 Answer

Changing the '2D Axis' 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