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 h8crew · Aug 21, 2013 at 03:45 PM · inputgetaxis

Windows 8 touch equivalent for 'Input.GetAxis("Mouse X")'

I'm trying to figure out an equivalent for Input.GetAxis("Mouse X") that will work with a windows 8 touch screen. I've searched everywhere and can't get a clear answer and everything I've tried hasn't worked.

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

2 Replies

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

Answer by h8crew · Aug 21, 2013 at 04:20 PM

Solved my own problem, thought I would post the answer here in case others stumble across this.

Set a Vector2 called 'oldMousePos' and another called 'curMousePos'. On update detect if oldMousePos == new Vector2(0,0), if so oldMousePos = curMousePos. Then make a new Vector2 called mouseDif and it should be oldMousePos - curMousePos. So what we have effectively done here is recreated a delta mouse position which works on Windows 8. You can then use these difference values for whatever you need.

Comment
Add comment · Show 3 · 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 TimBorquez · Oct 23, 2013 at 03:39 PM 0
Share

hey could you elaborate a tiny bit more please?

i have this

var cur$$anonymous$$ousePos = Input.mousePosition;

var old$$anonymous$$ousePos:Vector2;

if (old$$anonymous$$ousePos == new Vector2(0,0))

{

 old$$anonymous$$ousePos = cur$$anonymous$$ousePos;


}

var mouseDif = old$$anonymous$$ousePos - cur$$anonymous$$ousePos;

but im not really getting anything from this

avatar image h8crew · Oct 23, 2013 at 03:56 PM 0
Share

This is in c# but it shouldn't be hard to convert it.

 using UnityEngine;
 using System.Collections;
 
 public class delta$$anonymous$$ouse$$anonymous$$ovement : $$anonymous$$onoBehaviour {
     
     // Declare empty variables
     Vector2 old$$anonymous$$ousePos = Vector2.zero;
     Vector2 cur$$anonymous$$ousePos = Vector2.zero;
     Vector2 mouseDif = Vector2.zero;
     
     void Update () {
         // Get the current mouse position
         cur$$anonymous$$ousePos = Input.mousePosition;
         
         // If this is the 1st time this update has run, set the old mouse position to be the same as the current positon
         // This avoids 1 frame of potential jumping on start
         if (old$$anonymous$$ousePos == Vector2.zero)
         {
             old$$anonymous$$ousePos = Input.mousePosition;
         }
         
         // Get the difference between the last frame's position and this frame's position
         // This is your delta
         mouseDif = old$$anonymous$$ousePos - cur$$anonymous$$ousePos;
         
         // Set the old$$anonymous$$ousePos to the current value for use in the next frame
         old$$anonymous$$ousePos = Input.mousePosition;
     }
 }
 
avatar image TimBorquez · Oct 23, 2013 at 04:05 PM 0
Share

thanks so much for the quick response! ill look it over

avatar image
0

Answer by Peter G · Aug 21, 2013 at 03:52 PM

I haven't ever developed for the windows 8 touch screen so I don't know if it works with Input.GetTouch(), but if it does, then you should be able to do:

   var touch = Input.GetTouch(0);
   var deltaX = touch.deltaPosition.x;
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 h8crew · Aug 21, 2013 at 04:13 PM 0
Share

Unfortunately unity doesn't detect windows 8 touch by default like that. I did however come up with an easy solution, posting it as answer below.

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

17 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

Related Questions

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

[SOLVED] Input.GetAxis("Horizontal") returns wrong value? -1 Answers

How do I use an Xbox controller axis other than the left thumbstick? 0 Answers

How to get ScrollWheel values using a laptop touchpad? 1 Answer

Achieve framerate independent AddTorque rotaion with mouse drag. 2 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