Unity Roll a ball help

Hi

I have created the Unity roll a ball game in Unity 5 as shown in the tutorial section.

The problem I have is when I build the game for deployment for example in web player mode or as a windows game, I build and play the game but the first time you to collect one of the cubes the machine seems to slow down / freeze for a second or so which is noticable. After that collecting cubes is fine but the first time it seems to have a problem. I guess it must be to do with the first time OnTriggerEnter is called but I cant understand why it is having this problem because when I preview the game in Unity I dont have this slow issue.

Can someone advise how this can be fixed as I would like to start creating a game but I need to resolve this before proceeding.

My code is shown here:

using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private int count;
public GUIText countText;
public GUIText winText;
void start(){
count = 0;
SetCountText ();
winText.text = “”;
}
void FixedUpdate(){
float moveHorizontal = Input.GetAxis (“Horizontal”);
float moveVertical = Input.GetAxis (“Vertical”);
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
GetComponent().AddForce (movement * speed * Time.deltaTime);
}

void OnTriggerEnter (Collider other) {
if (other.gameObject.tag == “PickUp”)
{
other.gameObject.SetActive (false);
count = count +1;
SetCountText ();
}
}
void SetCountText(){
countText.text = "Count: " + count.ToString ();
if (count >= 10) {
winText.text = “You Win!”;
}
}
}

Thanks

Cecilcp

i have a similar issue, my roll a ball works fine in unity. but when i export to play the game, the ball just rolls threw the object and nothing happens.

just in case heres the coding

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Player_Controller : MonoBehaviour
{

public float Speed;
public Text CountText;
public Text winText;

private Rigidbody rb;
private int Count;

void Start()
{
rb = GetComponent();
Count = 0;
SetCountText ();
winText.text = “”;
}

void FixedUpdate()
{
float MoveHorizontal = Input.GetAxis(“Horizontal”);
float MoveVertical = Input.GetAxis(“Vertical”);

Vector3 Movement = new Vector3(MoveHorizontal, 0.0f, MoveVertical);

rb.AddForce(Movement * Speed);
}

void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag(“Pick Up”))
{
other.gameObject.SetActive(false);
Count = Count + 1;
SetCountText ();
}
}
void SetCountText()
{
CountText.text = "Count; " + Count.ToString();
if (Count >= 11)
{
winText.text = “You Win!”;
}
}
}

Are you still encountering this issue?