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 benk0913 · Sep 14, 2012 at 05:59 AM · rotationshooteraimsidescrollertransform.lookat

Unity, Y U IGNOR MY Y?

I have been trying to get my sidescroller shooter character to turn aside when the Y is higher than 90.

This is what I did:

 mousepos=Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y,2));
 mousepos.x=0;
 
 if(hands.transform.rotation.y>90)
        {
        if(facefor)
          {
          facefor=false;
          me.transform.rotation=new Quaternion(0,0,0,0);
 
          }
        else if(!facefor)
            {
               facefor=true;
              me.transform.rotation=new Quaternion(0,-180,0,0);
 
            }
         }
        else
        {
          if(facefor)
           hands.LookAt(mousepos,Vector3.right);
          if(!facefor)
           hands.LookAt(mousepos,Vector3.left);    
        }


But unity ignors the Y and keeps rolling with no switch! What could I do to make things right?

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 JMAA · Oct 10, 2012 at 11:09 AM 0
Share

Perhaps you can debug it with print() functions inside and outside the conditions and see if it enters them. That's what it suggests me.

avatar image Jessespike · Dec 03, 2012 at 09:20 PM 0
Share

I'm not a quaternion expert, but I don't think you should be doing this: me.transform.rotation=new Quaternion(0,-180,0,0); Also if you're Y rotation is greater than 360, then it will repeat back at 0!

2 Replies

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

Answer by benk0913 · Jan 30, 2013 at 01:17 PM

I have used a vector2 and made it to switch directions when the mouse crosses the middle. :)

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
avatar image
0

Answer by DaveA · Sep 14, 2012 at 07:00 AM

Use transform.eulerAngles.y instead

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 benk0913 · Oct 10, 2012 at 10:50 AM 0
Share

Doesnt works, it just keeps ignoring

avatar image TheDarkVoid · Dec 03, 2012 at 11:02 PM 0
Share

maybe Y axis is not what you need, try debuging all axies with a before applying rotation and after applying rotation and maybe there is something reseting the Y before the frame is rendered.

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

13 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

Related Questions

Unity is ignoring the minus 4 Answers

Help with 2d platform shooter aim 0 Answers

Vertical auto-aim with raycasts 1 Answer

Firing a projectile from orbit 1 Answer

Third Person Aiming 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