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 Nexgea · Sep 27, 2014 at 09:14 AM · touchandriod

Get current touch position

Hi, I have need touch position, Touch.position dont work.

I dont know why?

 #pragma strict
 var position: Vector2;
 function Start () {
 Touch.position = position;
 }
 
 function Update () {
 
 }

Error says : An instance of type 'UnityEngine.Touch' is required to access non static member 'position'.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by 767_2 · Sep 27, 2014 at 09:16 AM

     var touch: UnityEngine.Touch;
     touch.position = position;
 
Comment
Add comment · Show 14 · 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 Nexgea · Sep 27, 2014 at 09:18 AM 0
Share

Same error stil not working

avatar image 767_2 · Sep 27, 2014 at 09:22 AM 0
Share

check this

avatar image Nexgea · Sep 27, 2014 at 09:22 AM 0
Share

sry diffrent error : An instance of type 'UnityEngine.Touch' is required to access non static member 'position'.

avatar image 767_2 · Sep 27, 2014 at 09:24 AM 0
Share

checked it check it

avatar image Nexgea · Sep 27, 2014 at 09:27 AM 0
Share

now I getting weird error (5,18) UCE0001: ';' expected. Insert a semicolon at the end.

 var position: Vector2;
 function Start () {
 UnityEngine.Touch touch;
     touch.position = position;
 }
 
 function Update () {
 
 
 
 }
Show more comments
avatar image
0

Answer by Nexgea · Sep 27, 2014 at 10:36 AM

Ok so I finnaly make it i = Input.GetTouch(0).position;

HUGE thanks for 767_2 for helping me !!!!!

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 767_2 · Sep 27, 2014 at 10:38 AM 0
Share

so put my answer to correct so i can get on

avatar image
0

Answer by Wealsegun · Sep 27, 2014 at 12:34 PM

Type this var position: Vector2; function Start () { UnityEngine.Touch touch; touch.position = position; }

 function Update () {
  
  
  
 }
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 TheFloatingSheep · Sep 30, 2014 at 09:29 PM

Something like this?

 function Update () {            
     for (var i = 0; i < Input.touchCount; ++i) {
         Touch touch = Input.GetTouch(i);
         if (touch.phase == TouchPhase.Began) {
            if (touch.position > (Screen.width/2)) {
                 //do something
            }
         }
     }
 }
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

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

28 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

Related Questions

Double Touch Tap to Select Android 0 Answers

Touch Input for character control using mechanim 0 Answers

Inertia Scrolling Touch 1 Answer

Multi touch not working - What's wrong with this code? 1 Answer

How to determine input device being used? 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