- Home /
 
 
               Question by 
               GalaxyHells · Nov 24, 2019 at 06:49 PM · 
                positiontouchvector2  
              
 
              Get touch position to create floating text,Get position from touch to spawn floating text
Hi, i don't speak english very well so i used google translator.
I tried using the touch screen position to create floating text in that location that will show how much money the player has earned in that click. But I guess I didn't even get the code right to get the right touch position, but I had tested it by setting fixed values and when creating the floating text it is born with an absurdly high position, like 26000.
Cod:
 public void ClickTheMainButton() {
         ModGeneral.MoneyCount += ModGeneral.MoneyPerClick;
         ModGeneral.Exp += (int)ModGeneral.MoneyPerClick;
         ModGeneral.MoneyAllTime += ModGeneral.MoneyPerClick;
 
         FloatingTextController.CreateFloatingText("+" + ModGeneral.MoneyPerClick + " Money", new Vector2(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y));
     }
 
                public static void CreateFloatingText(string text, Vector2 location)
         {
             Debug.Log(location.x);
             FloatingText instance = Instantiate(popupText);
             Vector2 screenPosition = Camera.main.WorldToScreenPoint(new Vector2(location.x, location.y));
     
             instance.transform.SetParent(canvas.transform, false);
             instance.transform.position = screenPosition;
             instance.SetText(text);
         }
 
              
               Comment
              
 
               
              Your answer