- Home /
 
              This question was 
             closed Sep 16, 2014 at 09:00 AM by 
             RedDevil for the following reason: 
             
 
            managed to solve it on my own
Unity2D move object by touch input
Hi.I have this game where i instantiate a lot of 2D game objects and I want so that when i touch one of these objects that they would then start moving.The problem I am curently facing is that i get an instant crash.
I curently have rigidbodys 2D and 2D circle colliders and the touch detection script on each of these objects. Here is the touch detection script from one of the objects:
 void Update()
     {
         if( Input.touchCount >= 1 )
         {
             Ray cursorRay = Camera.main.ScreenPointToRay( Input.GetTouch(0).position );
             RaycastHit hit;
             if( collider.Raycast( cursorRay, out hit, 1000.0f ) )
             {
                 this.transform.Translate(Vector2.up * 10 * Time.deltaTime);
                 gameManager.choice = true;
             }
         }
     }
 
               Please help.Thank you
               Comment
              
 
               
              Follow this Question
Related Questions
Taps are not detected on mobile 1 Answer
What's the right way to detect double tap on a phone? 0 Answers
Inertia Scrolling Touch 1 Answer
How to destroy object by touch? 2 Answers