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 /
This question was closed Apr 25, 2013 at 04:11 PM by Fattie for the following reason:

Duplicate Question

avatar image
-2
Question by manjunathreddy · Apr 25, 2013 at 02:19 PM · gettouch

help with touch versus keyboard controls

i have a script that can be controle a object by mouse(up,down,right,left) but i need to control object by using touch instead of mouse keyboard?i am new to unity3d

this is my script in this i want to simple camera walk through using andriod

pragma strict

function Start () {

}

function Update () {

//------------------Code for Zooming Out------------

if (Input.GetAxis("Mouse ScrollWheel") <0)

    {

if (Camera.main.fieldOfView<=100)

Camera.main.fieldOfView +=2;

if (Camera.main.orthographicSize<=20)

                                Camera.main.orthographicSize +=0.5;

    }


//----------------Code for Zooming In-----------------------

 if (Input.GetAxis("Mouse ScrollWheel") > 0)

    {

 if (Camera.main.fieldOfView>2)

 Camera.main.fieldOfView -=2;

 if (Camera.main.orthographicSize>=1)

                             Camera.main.orthographicSize -=0.5;

    }

 

//-------Code to switch camera between Perspective and Orthographic-------- if (Input.GetKeyDown("down"))

{

if(Camera.main.transform.localPosition.x>-3&&Camera.main.transform.localPosition.x<=3){ Camera.main.transform.localPosition.x -=.1; }

}

  if (Input.GetKeyDown("up"))

{

if(Camera.main.transform.localPosition.x>=-3&&Camera.main.transform.localPosition.x<3){ Camera.main.transform.localPosition.x +=.1; }

}

  if (Input.GetKeyDown("left"))

{ if(Camera.main.transform.localPosition.z>=11&&Camera.main.transform.localPosition.z<16){ Camera.main.transform.localPosition.z +=.1; }

} if (Input.GetKeyDown("right"))

{ if(Camera.main.transform.localPosition.z>11&&Camera.main.transform.localPosition.z<=16){ Camera.main.transform.localPosition.z -=.1; }

}

}

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 AlucardJay · Apr 25, 2013 at 02:19 PM 1
Share

Read this page : http://answers.unity3d.com/page/newuser.html

For any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window.

Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers

avatar image Fattie · Apr 25, 2013 at 04:10 PM 0
Share

Title is too long, Pasted code is not formatted. Question asked 100s of times.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Graham-Dunnett · Apr 25, 2013 at 03:07 PM

Check out the documentation for advice about using the touch screen on mobile devices. And try this code:

 function OnGUI() {
     GUI.Label (Rect (10, 10, 100, 35), "Touches");
     for (var i : int = 0; i < Input.touchCount; ++i) {
         var t : Touch = Input.GetTouch(i);
         var p : Vector2 = t.position;
         GUI.Label (Rect (10, 35*(i+1), 500, 35), "Touch " + i + ": (" + p.x + ", " + p.y + "){"+ t.fingerId+"}" + t.phase);
     }
 }

That should allow you to see the touches, their positions etc as you touch the screen.

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

Follow this Question

Answers Answers and Comments

14 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

Related Questions

unity 5.2 Input.GetTouch(0).position incorrect? 3 Answers

Get Touch touch phase began is grounded not working 2 Answers

Touches, fingerID's and changing them. 1 Answer

Help with iTouch control bug 0 Answers

Why is my Touches array empty? 1 Answer


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