Search Unity

Android - Code working in Unity Remote but not in Build

Discussion in 'Android' started by Haykys, Apr 19, 2019.

  1. Haykys

    Haykys

    Joined:
    Mar 12, 2019
    Posts:
    13
    Hey there

    I have the following code

    Code (CSharp):
    1. // User has tapped
    2.             if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
    3.             {
    4.                 var isTouchingFloor = GetComponent<BoxCollider2D>().IsTouchingLayers(LayerMask.GetMask(Floor));
    5.  
    6.                 if (Time.time - touchTime <= 0.5 && isTouchingFloor)
    7.                 {
    8.                     Vector2 jumpVelocityToAdd = new Vector2(0f, 30f);
    9.                     myRigidbody2D.velocity += jumpVelocityToAdd;
    10.                 }
    11.             }
    Which works in Remote but not in build (it is suppose to make the player jump)

    Any idea why it is so ?