Search Unity

Feedback Roll-a-ball - Game works fine in editor - build version does not display "you win".

Discussion in 'Community Learning & Teaching' started by steambucky, Sep 12, 2020.

  1. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Hello,

    When I play the game in the unity editor the game works as expected. No errors in the console. The build version the does the same BUT does not display "YOU WIN!" I looked for similar reports fo this bug, but failed to find anything.

    Here is the code for for the player controller. please let me know if you need to see anything else.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5. using TMPro;
    6.  
    7.  
    8. public class PlayerController : MonoBehaviour
    9.  
    10. {
    11.     public float speed = 0;
    12.     public TextMeshProUGUI countText;
    13.     public GameObject winTextObject;
    14.  
    15.     private Rigidbody rb;
    16.     private int count;
    17.     private float movementX;
    18.     private float movementY;
    19.  
    20.  
    21.     // Start is called before the first frame update
    22.     void Start()
    23.     {
    24.  
    25.         rb = GetComponent<Rigidbody>();
    26.         count = 0;
    27.  
    28.         SetCountText();
    29.         winTextObject.SetActive(false);
    30.     }
    31.  
    32.     void OnMove(InputValue movementValue)
    33.     {
    34.         Vector2 movementVector = movementValue.Get<Vector2>();
    35.  
    36.         movementX = movementVector.x;
    37.         movementY = movementVector.y;
    38.     }
    39.  
    40.     void SetCountText()
    41.     {
    42.         countText.text = "Count: " +count.ToString();
    43.         if (count>=12)
    44.         {
    45.             winTextObject.SetActive(true);
    46.         }
    47.     }
    48.  
    49.  
    50.     void FixedUpdate()
    51.     {
    52.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    53.  
    54.         rb.AddForce(movement * speed);
    55.     }
    56.  
    57.     //removes picksup on collision and adds 1 to count
    58.     private void OnTriggerEnter(Collider other)
    59.     {
    60.         //is it a pick up?
    61.         if (other.gameObject.CompareTag("PickUp"))
    62.         {
    63.             //deactives the pick up
    64.             other.gameObject.SetActive(false);
    65.             // adds one to the count
    66.             count = count + 1;
    67.  
    68.             //This updates the on screen count
    69.             SetCountText();
    70.         }
    71.     }
    72. }
    73.  

    player settings.png

    I get the impression that i have coded something wrong that editor is some how "forgiving", and still working anyway...

    I am running this on a mac OSX 10.15.16 Unity is Version 2019.4.10f1 personal. Couldn't find anything in the known issues.

    Can you assist? Any ideas of things i should check? Thanks in advance for any help you can supply.

    Kind Regards,

    Marc
     
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481