Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Nov 29, 2016 at 02:20 PM by Mr_TK for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by Mr_TK · Nov 29, 2016 at 08:54 AM · movementmousemousepositionmouse positionmouse button

getting maximum x and y values of mouse position

hey. I want to get maximum x and y values of mouse position when the player pressing the mouse key. i got the values of all the x's and y's. but i can't figure out how can i eliminate maximum ones and stock in variables. here's my code:

 void FixedUpdate () {
 
 
 
         if (Input.GetMouseButton (0)) {
             
             Vector3 posa = Camera.main.ScreenToWorldPoint (Input.mousePosition);
 
             float x = posa.x;
             float y = posa.y;
                             
             Debug.Log (x);        
                         Debug.Log (y);
         }
     
     }    
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 Crash0 · Nov 29, 2016 at 10:18 AM 0
Share

What do you mean by max values ?

avatar image Mr_TK Crash0 · Nov 29, 2016 at 10:57 AM 0
Share

alt text

so this is my console. those values are x position of my mouse when i press and swipe my mouse. i want to get the biggest value ( in this pic it's 0.2375) and use it as a vector in order to move an object. i want to make simple swipe gesture or something like that. by the way i am new at coding.

adsız.jpg (42.3 kB)

1 Reply

  • Sort: 
avatar image
0

Answer by rjth · Nov 29, 2016 at 10:59 AM

Your maximum mouse position value will always be the current screens width or height.

For x axis use Screen.width, for the y Screen.height.

Comment
Add comment · Show 1 · 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 Mr_TK · Nov 29, 2016 at 11:11 AM 0
Share

alt text I am sorry i couldn't explain myself. i can already get V1. it's not a problem. so my object moving in a straight path. but i want to add some curves to movement. so i think if i could get maximum x position that mouse reached when it's pressed and use it as a vector and at some point later if i give the opposite x vector my object will move curvedly.

adsız.jpg (73.1 kB)

Follow this Question

Answers Answers and Comments

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

Related Questions

Making GameObject move in the direction of my mouse (3d) 0 Answers

Mouse control 0 Answers

How to control global mouse 0 Answers

How to have units in a formation when moving/arriving at mouse location (RTS Style)? 0 Answers

Why is my MouseLook script not letting me look up? 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