- Home /
 
               Question by 
               YAZER_ · Dec 04, 2019 at 12:44 AM · 
                controllertouch controlscontroltouchscreen  
              
 
              controling an 3d object with touch screen..
Hello İ have an 3d object and i want to drag it with touch screen on X and Z and keep it moving on Y axis
here is my code
void Update(){
if (Input.touchCount > 0) {
        Touch touch = Input.GetTouch(0);
        touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
        touchPosition.z = 0;
        Direction = (touchPosition - transform.position);
        rb.velocity = new Vector2(Direction.x, Direction.z) * moveSpeed;
       if (touch.phase == TouchPhase.Ended)
       rb.velocity = Vector3.zero;
              }
}
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
OnDrag methods not being called on Android in Unity 2018.3.5f1 3 Answers
Problem in multi touch 0 Answers
Count Number of Touches made in Android 2 Answers
Tap Control on Android 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                