Android: Hiccups in simple scene - related to time
I am trying to finish my first game made in Unity, everything is ready but I have a very annoying problem. When I play the game on an Android device I face an annoyance that multiple other people have been posting about without really finding any solution. I have tried everything when it comes to optimizing but without any luck eliminating the problem.
I thought this was really strange so I started a new project with only 1 scene containing a camera and a sprite with a simple script attached.
using UnityEngine;
using System.Collections;
public class Character : MonoBehaviour {
// Update is called once per frame
void Update ()
{
transform.Translate (Vector2.right * 10 * Time.deltaTime);
}
}
And what do you know? This very simple scene also caused the "hiccups" or studdering on my Android device. I was pretty confused by this realization, how can such a simple scene cause hiccups? I still don't know the answer but today I think I might have identified what is causing the problem. What I did was I changed the line of code that moves the character from transform.Translate (Vector2.right * 10 * Time.deltaTime);
to
transform.Translate (Vector2.right * 0.15f);
For the first time the project was running without any studdering or hiccups on my Android device. I understand that this is not a good code but it has made me realise that the problem must be with Time.deltaTime.
In my actual game the character has a rigidBody2D attached to it and is moved by setting rigidBody2D.velocity. So I tried to replicate this in my "testing project". I added the rigidBody2D component to the sprite. I set the gravityscale to 0 and turned on Interpolation. To move the sprite now with the rigidBody2D component I attached the script was changed to this:
using UnityEngine;
using System.Collections;
public class Character : MonoBehaviour {
private Rigidbody2D playerBody;
// Use this for initialization
void Start()
{
playerBody = GetComponent<Rigidbody2D> ();
playerBody.velocity = new Vector2 (10, 0);
}
}
And once again this simple scene is causing studdering in my Android device every few seconds and it is horrible for the eye. Could this be related to the fixed timestep or perhaps something needs to be changed in the Physics2D settings? (I am using the default settings). I am so fed up with not being able to finish my game due to this annoying studdering and I have not been able to find any solution online. I desperately need some help or perhaps some ideas what I can try to make the studdering go away.
Thank you in advance - Otto
Your answer
Follow this Question
Related Questions
Returning abnormal values with Time.deltaTime and Time.unscaledDeltaTime. 0 Answers
[Android] When App closed get time when player was gone? 1 Answer
C# How to have a scripted if statement last x amount of seconds 1 Answer
Light intensity Lerp not functioning properly 1 Answer
Time.deltaTime and difference of Time.time not matching 0 Answers