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 Apr 02, 2016 at 04:35 PM by meat5000 for the following reason:

Common question. Please search and dont ask for scripts.

avatar image
0
Question by ThunderStrikeBlue · Mar 31, 2016 at 10:03 PM · c#unity5touchscreen

Need some help with Touchscreen Input.

I am new to Unity and I'm making a Infinite Runner that runs along the z axis. I have procedural generation, score system, and a working movement system that uses the Horizontal Axis to move left and right. Does anyone know how I could change the 'a' and 'd' inputs to touchscreen where by pressing the left side of the screen, the character would move left, and by pressing the right side, the character would move right? Thanks for helping, but I'm only interested in C# scripts

Comment
Add comment · Show 1
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 meat5000 ♦ · Apr 02, 2016 at 04:34 PM 0
Share

This is a common question and is easily searchable.

https://www.google.co.uk/search?q=nuity+touch+movement&ie=utf-8&oe=utf-8&client=ubuntu&channel=fs&gfe_rd=cr&ei=X_T_Vr6p$$anonymous$$t$$anonymous$$CaJzQsZAF&gws_rd=ssl

Please search before posting.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by malta32 · Apr 01, 2016 at 04:04 AM

could you try detecting which side of the screen you push? Something like....

 using UnityEngine;
 using System.Collections;
 
 public class Split : MonoBehaviour {
 
 
     float width;
     // Use this for initialization
     void Start ()
     {
         width = Screen.width / 2;
     }
     
     // Update is called once per frame
     void Update ()
     {
         if (Input.touches.Length > 0)
         {
             if (Input.touches[0].position.x > width)
             {
                 Debug.Log("Right");
             }
             else
             {
                 Debug.Log("Left");
             }
         }
     }
 }

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 ThunderStrikeBlue · Apr 01, 2016 at 07:09 AM 0
Share

Thanks! I just need to wire up the Debug Log to movement now right?

avatar image malta32 · Apr 02, 2016 at 03:59 PM 0
Share

Yes, just replace the right and left debug messages with what you want to happen when the right and left sides of the screen are pushed.

if(.....x > width) { myUnit.$$anonymous$$oveOrder($$anonymous$$oveDirection.Right); }

Or however you are letting the unit know which way to move.

avatar image ThunderStrikeBlue malta32 · Apr 03, 2016 at 09:26 AM 0
Share

Thanks so much! That really helped. I really appreciate your answer.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I measure the velocity of object in Z-direction? 0 Answers

Canvas Sorting Layer having issues with Horizontal Layout Group (And override sorting is not working) 1 Answer

Why does NetworkServer.ReplacePlayerForConnection not recognize the instantiated object parameter? 0 Answers

Gizmos and Handles 1 Answer

unity3d 5 game on fullscreen shows only half of game screen 4 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