Working on a very simple pong style game, I have two scripts which cause the game to skip / stutter for the first few seconds of the scenes loading up. If I remove these two scripts, the stuttering goes away. It seems to stabilize after 10-15 seconds and only happens when the level first starts. However, since this game is physics based and the ball is always moving, any skipping, stuttering or slowdown is visible.
I am seeing the stuttering issue on an iPhone 5 but it is not visible on the engine Game window. Using the free version of Unity, I do not have access to the profiler.
Any ideas why these two bits of script are causing stuttering issues?
Thank you
This is a countdown timer. When the timer reaches zero, the game advances to the next level.
//Countdown Timer (Visible)
var endTime : float;
var textMesh : TextMesh;
function Start()
{
endTime = Time.time + 63;
textMesh = GameObject.Find ("Text_Timer").GetComponent(TextMesh);
textMesh.text = "63";
}
function Update()
{
var timeLeft : int = endTime - Time.time;
if (timeLeft < 0) timeLeft = 0;
textMesh.text = timeLeft.ToString();
}
//End level and load win screen after X Seconds (Invisible)
var timeLimit : float = 63; // 1 minute timer
Invoke("NextMap", timeLimit);
function NextMap()
{
Application.LoadLevel("Win");
}
This is a quit game button which takes the player back to the main menu.
private var ray : Ray;
private var rayCastHit : RaycastHit;
//Load Previous button
function LateUpdate ()
{
//Load Previous Level
if(Input.GetMouseButtonDown(0))
{
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, rayCastHit))
{
if(rayCastHit.transform.name == "Text QuitToMenu")
{
Application.LoadLevel("L0.0 Menu");
}
}
}
}