- Home /
Game freezes for 10+ seconds on start
Every time I hit the play button or build & run, the game loads up, but stays halted for 10-12 seconds before it actually lets me do anything. My game has a textured plane, and a model with 2 attached particle systems. There's a script attached to the model which controls its movement & look at mouse functionality. I've taken out each piece of that functionality and tested with what remained, but nothing changed. It's not Unity freezing up, as I can still click the play button again to stop.
Any help will be greatly appreciated, and let me know if you need anymore information. Thanks.
Edit - I guess the package is too big to be attached. It's ~550k. Here's the code:
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
private float accel = 1000.0f;
private Vector3 movementVec;
private Vector3 rotationVec;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 mousePos = Input.mousePosition;
rotationVec = new Vector3(mousePos.x, mousePos.y, Camera.main.transform.position.y - transform.position.y);
Vector3 world = Camera.main.ScreenToWorldPoint (rotationVec);
transform.LookAt (world);
movementVec = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis ("Vertical"));
rigidbody.AddForce(movementVec.normalized * accel * Time.deltaTime, ForceMode.Acceleration);
foreach(Transform child in GetComponentsInChildren(typeof(Transform)))
{
if(child.name == "Thruster")
{
if(Input.GetKey (KeyCode.W) || Input.GetKey (KeyCode.A) || Input.GetKey (KeyCode.S) || Input.GetKey (KeyCode.D))
{
child.particleSystem.enableEmission = true;
}
else
{
child.particleSystem.enableEmission = false;
}
}
}
}
}
Well it must be something :) Are you sure it isn't Unity recompiling? If not then it must be some kind of script given the simplicity of the scene.
That's what I thought at first, but I asked a friend of $$anonymous$$e who uses it and he's never run into this with much more intricate scenes. I just looked at the stats while it's running and it does look like it's updating as time is changing, FPS is counting, etc..., it just doesn't seem to run my script for a while.
I will admit, I'm a bit of a newbie (see: total) at Unity, so maybe it's just something small I'm not picking up on.
I guess you aren't using Pro - so we don't have the profiler....
Answer by Sodabread · Jun 20, 2012 at 01:43 PM
Looks like the issue was that I had an animation controller on the object and it was set to play on startup. I took that off and everything starts immediately as it should. Thanks for the help, folks.
Your answer
Follow this Question
Related Questions
Weapon Movement Freezing 0 Answers
Unity 5.1.1 Linux Ubuntu when i hit the play button it freezes and wont do anything 0 Answers
Unity (2018.2f and 5.6) Freezes when using While Loop for countdown timer in coroutine. 3 Answers
Freeze when building 0 Answers
Unity (randomly) freezing on play 1 Answer