Stuttering in build
Hi
Whilst working on my first project I experienced stuttering in editor which I managed to improve however there is still significant stuttering in the motion of hazards when I build and export to an android device. There is also some, but lest frequent, stuttering in the main menu animations. I was wondering if anyone could suggest any fixes or help point out errors in my code that could lead to stuttering.
Many Thanks :)
Here is the corouting I am using to spawn hazards, called in start.
IEnumerator SpawnWalls()
{
yield return new WaitForSeconds(startWait);
while (gameOver == false)
{
velocity += acceleration;
Vector3 spawnPosition = new Vector3(spawnPoint.transform.position.x, 0.5f, spawnPoint.transform.position.z);
Quaternion spawnRotation = Quaternion.identity;
Instantiate(walls[Random.Range(0, walls.Length)], spawnPosition, spawnRotation);
spawnWait = wallSpacing / velocity;
yield return new WaitForSeconds(spawnWait);
}
}
Here is the script attached to the hazards to give them the desired velocity
public class mover : MonoBehaviour {
public GameObject gameController;
private Rigidbody rb;
void Start ()
{
gameController = GameObject.Find("GameController");
rb = GetComponent<Rigidbody>();
float spawnForce = (gameController.GetComponent<GameController>().velocity) * -50f;
rb.velocity = new Vector3(0.0f, 0.0f, -gameController.GetComponent<GameController>().velocity);
//rb.AddForce(0.0f, 0.0f, spawnForce);
}
void FixedUpdate ()
{
if (transform.position.z < -10)
{
Destroy(gameObject);
}
}
}
Answer by shawnatkidzpace · Jun 14, 2019 at 04:36 PM
Try using the profiler or physics debugger when running the game
I will give this a try, however I believe the stuttering isn't due to fps drops. When I was experiencing stuttering in the editor it would often occur even if the frame rate was high.
Just used profiler. I have 93.1% on Editor Loop and only 6.3% on Player Loop. Not sure what the editor loop is though.
I just used an fps counter asset (ins$$anonymous$$d of unitys built in tracker). Whereas the built in tracker was showing around 120fps in the editor the counter asset shows the frame rate capped at 30fps and uncapping it doesn't seem to be working. I also used the asset whilst running the game on an android device which showed an average fps of around 25fps.
Can I get rid of the usage on the editor loop to boost these numbers?
Your answer
![](https://koobas.hobune.stream/wayback/20220612203216im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
APK filename change on build & run, Copy error (PostProcessBuildAttribute) 0 Answers
CommandInvokationFailure: Unable to convert classes into dex format. 1 Answer
Voxel Busters Plugin & Admob build crash 0 Answers
Trees look flat on mobile using standard shader 0 Answers
Admob unity 2017.3 compile error 0 Answers