- Home /
 
 
               Question by 
               PeterWendig · Jan 08, 2016 at 07:56 AM · 
                2dspritesprites  
              
 
              Sprite disappears on android
I am programming a game in 2D for android and pc/mac. The sprite is the same and it's visible on the pc/mac. But once I use android and move the sprite, it disappears. The code is this: what could be the reason?
This is what it looks like(keep it on imgur only):
http://i.imgur.com/CPYoju7.gif
 #if UNITY_ANDROID
 
 
         float MitteX = Screen.width - 80;
         float MitteY = 80;
         float x = Input.touches[0].position.x - MitteX;
         float y = Input.touches[0].position.y - MitteY;
         if (Input.touches[0].position.x > Screen.width - 160 && Input.touches[0].position.y < 160)
         {
             if (!anim.GetBool("istTot"))
             {
                 float r = Mathf.Sqrt(Mathf.Pow(x, 2) + Mathf.Pow(y, 2)) / 100;
                 ////if (umdrehen)
                 ////    ve = -Input.GetAxis("Vertical");
                 ////else
                 ////    ve = Input.GetAxis("Vertical");
                 if (r > 0.5f)
                 {
                     r = 1.5F;
                     KameraAbstand = 50;
                 }
                 else
                     KameraAbstand = 20;
 
                 anim.SetFloat("Geschwindigkeit", r);
                 Vector2 n = new Vector2(x, y).normalized;
                 rb.velocity = n * maxGeschwindigkeit;
                 rb.transform.right = n;
                 //neu.text = r + "\n" + n.x + " " + n.y;
                 if (rb.transform.right.x < 0)
                 {
                     Vector3 skalJetzt = transform.localScale;
                     skalJetzt.y = -1;
                     transform.localScale = skalJetzt;
                 }
                 else
                 {
                     Vector3 skalJetzt = transform.localScale;
                     skalJetzt.y = 1;
                     transform.localScale = skalJetzt;
                 }
             }
         }
         else
             anim.SetFloat("Geschwindigkeit", 0);
 #else
             float ho = Input.GetAxis("Horizontal");
             float ve = 0;
             if (umdrehen)
                 ve = -Input.GetAxis("Vertical");
             else
                 ve = Input.GetAxis("Vertical");
             if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
             {
                 ve *= 1.5F;
                 KameraAbstand = 50;
             }
             else
             {
                 KameraAbstand = 20;
             }
             
 
             anim.SetFloat("Geschwindigkeit", Mathf.Abs(ve));
             if (!anim.GetBool("istTot"))
             {
                 rb.velocity = new Vector2(ve * maxGeschwindigkeit * transform.right.x, ve * maxGeschwindigkeit * transform.right.y);
 
                 rb.transform.Rotate(Vector3.back, ho);
             }
             //Debug.Log(transform.right.y + " " + transform.right.x);
             //if ((ho > 0 && !rechtsSchauen) || (ho < 0 && rechtsSchauen))
             //    Drehen();
             if (transform.right.x < 0)
             {
                 Vector3 skalJetzt = transform.localScale;
                 skalJetzt.y = -1;
                 transform.localScale = skalJetzt;
             }
             else
             {
                 Vector3 skalJetzt = transform.localScale;
                 skalJetzt.y = 1;
                 transform.localScale = skalJetzt;
             }
 #endif
 
              
               Comment
              
 
               
              Your answer