Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 fakabaka · Aug 13, 2015 at 10:30 AM · androidlinerenderermultitouchdrawlinefingerid

Drawing 2 lines in same time

hi, im now currently making a drawing game using a method to draw lines but i do not know is it the best way to do what i am up to is to create an object which with line renderer with it, the object is following my touch as i move along, it completly works with if only 1 line is drawing however i need it to be 2 line drawing most likely at the same time, so i can draw 2 line seperately.

the following is my coding

 using UnityEngine;
 using System.Collections;
 
 public class TouchDrawMethod : MonoBehaviour {
         
     public GameObject trailPrefabsR;
     public GameObject trailPrefabsL;
 
     bool canMoveR;
     bool canMoveL;
 
     void Start(){
         canMoveR = false;
     }
 
     void Update(){
 
              touchMethod();
 
     }
     
     void touchMethod(){
 
         int count = Input.touchCount;
         for(int i=0; i < count; i++){
             
             Touch touch = Input.GetTouch(i);
 
             if(touch.phase == TouchPhase.Began){
 
                 if(i == 0){
                 if(touch.position.x < Screen.width){
                     trailPrefabsR.transform.position = new Vector3((touch.position.x /Screen.width)*16 -8 , (touch.position.y / Screen.height) * 10-5, -8);
                     Instantiate(trailPrefabsR, trailPrefabsR.transform.position, transform.rotation);
                     canMoveR = true;
                     }
                 } else{
                     trailPrefabsL.transform.position = new Vector3((touch.position.x /Screen.width)*16 -8 , (touch.position.y / Screen.height) * 10-5, -8);
                     Instantiate(trailPrefabsL, trailPrefabsL.transform.position, transform.rotation);
                     canMoveL = true;
                 }
             }
 
             if(touch.phase == TouchPhase.Ended){
                 GameObject.FindWithTag("Right").tag = "null";
                 GameObject.FindWithTag("Left").tag = "null";
                 canMoveR = false;
                 canMoveL = false;
             }
 
             
             if (GameObject.FindWithTag ("Right") != null) {
                 
                 if (canMoveR)
                     GameObject.FindWithTag ("Right").transform.position = new Vector3 ((touch.position.x /Screen.width)*16 -8, (touch.position.y / Screen.height) *10 -5, -8);
                 else
                     GameObject.FindWithTag ("Right").transform.position = new Vector3 ((touch.position.x /Screen.width)*16 -8, (touch.position.y / Screen.height) *10 -5, 10);
             
             }
 
             if (GameObject.FindWithTag ("Left") != null) {
                 
                 if (canMoveR)
                     GameObject.FindWithTag ("Left").transform.position = new Vector3 ((touch.position.x /Screen.width)*16 -8, (touch.position.y / Screen.height) *10 -5, -8);
                 else
                     GameObject.FindWithTag ("Left").transform.position = new Vector3 ((touch.position.x /Screen.width)*16 -8, (touch.position.y / Screen.height) *10 -5, 10);
                 
             }
 
         }
     }
 }
 


with this, i can only draw 1 line at once although it detect there is two touch and instantiating 2 of my line renderer object, i think the problem is, it update my two touch point into same place thats why i cannot draw two line in the same time, it would be great if any of you can help me with this problem solving or any other better way to draw 2 lines in same time thankyou

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 fakabaka · Aug 13, 2015 at 10:56 AM 0
Share

i just think of a method, can i do it as

 touch.fingerId.position

but this comes me with an error, is this such a way to do or my code is something wrong?

0 Replies

· Add your reply
  • Sort: 

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

24 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

Related Questions

Multitouch Android touches excluding each other 1 Answer

FingerID problem 1 Answer

Multitouch sometimes doesn't work properly when fingers are close together. 1 Answer

¿Unity messing up fingerIDs? [Android] 1 Answer

Andriod Multitouch with joystick 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