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 merlijndev · Jan 07, 2013 at 10:11 PM · positionx axis

how to check if the object looks right or left?

i have a playercharachter which i want to play a different animation if it looks right or left, i have looked for code how to do this but i havent found anything that really helps does anyone knows? i'm using javascript

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 Mr.Z · Jan 07, 2013 at 10:28 PM

If what you want is to play different animations depending on where the player wants to move his character you can do it like this:

 if (Input.GetKeyDown ("yourkey")) {
        object.animation.Play( "animationName" ); 
    }
Comment
Add comment · Show 6 · 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 merlijndev · Jan 07, 2013 at 10:41 PM 0
Share

no i'm looking for the code that checks if the object has no movement

avatar image Itinerant · Jan 07, 2013 at 10:46 PM 0
Share

Hmm...if you want to know when an object isn't moving, first we need to know what causes it to move. Do you press a key to move left and right? Does it move by itself unless some other variable is present?

avatar image Mr.Z · Jan 07, 2013 at 10:51 PM 0
Share

also why didn't you ask that in the first place?

avatar image merlijndev · Jan 08, 2013 at 05:08 PM 0
Share

that was what i was asking my question says "how to check if the object looks right or left?"

avatar image Itinerant · Jan 08, 2013 at 05:17 PM 0
Share

Ooooh, now I think I get what you mean. You want to know if you're standing still, but the mouse is moved in one direction or the other? So the input you're using is the mouse axis, rather than a button.

You'll probably want to use some variation of if(Input.GetAxis("horizontal")){action}. You can check out the details on this call at http://docs.unity3d.com/Documentation/ScriptReference/Input.GetAxis.html, but the basics are that it provides you a number between -1 and 1 based on what you're doing with your mouse, and those numbers correspond to right and left.

If you're not sure what your horizontal axis is called, check out the input settings Edit > Project Settings > Input.

Show more comments

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

10 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

Related Questions

Moving an object to an x postion 1 Answer

Camera rotation around player while following. 6 Answers

x, y position to 360 degree 0 Answers

How to instantiate in self position. 1 Answer

Finding locations of Vertices on a Mesh 3 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