Question by 
               FoxAdventures · Apr 03 at 05:42 PM · 
                c#mobiletouchtouch controlstouchscreen  
              
 
              ScreenToWorldPoint on One Axis?
I'm trying to change my object's position via touchscreen only on X axis. If I don't add the "rigPos.y" line it works with no problem and the object changes its position on both x and y axes based on my finger's position. But I want the Y position to stay fixed and only the X position to change. But the way it is now, as soon as I press the screen the object goes to around -6 on Y axis for some reason.
Here is the code that I have thus far:
 Rigidbody rb;
 
     void OnEnable()
     {
         EnhancedTouchSupport.Enable();
 
         TouchSimulation.Enable();
     }
 
     void OnDisable()
     {
         EnhancedTouchSupport.Disable();
     }
 
     void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void Update()
     {
         if (Touch.activeFingers.Count > 0)
         {
             Run();
         }
     }
 
     void Run()
     {
         Touch touch = Touch.activeFingers[0].currentTouch;
         Vector3 rigPos = new Vector3(touch.screenPosition.x, touch.screenPosition.y, 10.0f);
         rigPos.y = -4.87f;
         rb.position = Camera.main.ScreenToWorldPoint(rigPos);
 
     }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                