Hello everyone,
I’ve spent a WEEK googling and searching before I decided to post here. I am writing a simple 2D scrolling game, where the character simply jumps over obstacles ( the world scrolls while he’s stationary). As you can imagine: a SMOOTH scrolling motion would be top priority for this type of gameplay.
As it turns out ( at least I think so) , Unity v. 4+ has an ugly “hiccup / stutter” problem which ONLY 2 POSTS ?? were made about ? Do people not test their games on actualy mobile devices or am I really doing somethign wrong ?
THE PROBLEM: Create a new 2D project, setup a cube or a ball, and move it with trasnform.position from one corner to another. Then push it to your Android device (didn’t try iPhone yet). Result ? Every second or so, framerate drops, the ball stops moving and the whole thing stops for a tiny moment. When it finally wakes up, Time.deltaTime moves it with a big jump to compensate for the lost time, and the whole game is ruined. Not only it looks ugly, but the Player can easyly loose the game because he couldn’t react fast enough to the moving obstacle.
I found TWO threads talking about this, TWO ?!?! really ?
- Update/FixedUpdate motion stutter (Note: This is NOT a novice deltaTime question) - Questions & Answers - Unity Discussions
and - http://forum.unity3d.com/threads/203552-Stuttering-issue-on-Unity-4-2
Neither of those two guys got it resolved. One person submitted a Bug report under Case 567610 . This was 6 months ago. I don’t know how to check for current progress on bugs. Can someone please tell me where to find bugs by their Case numbers ?
I know people here will ask me to submit the code, so here it is
public class Move : MonoBehaviour {
public float speed;
private float avg;
float lastframe = 0f;
float currentframe = 0f;
float myDelta = 0f;
float motion_multiplier = 1.0f;
void Awake()
{
Application.targetFrameRate = 30;
}
void Update()
{
currentframe = Time.realtimeSinceStartup;
myDelta = currentframe - lastframe;
lastframe = currentframe;
}
void LateUpdate ()
{
//avg = (Time.deltaTime + Time.smoothDeltaTime)*0.5f;
avg = (Time.deltaTime + Time.smoothDeltaTime + myDelta)*0.33333f;
transform.position += new Vector3(speed*motion_multiplier, 0f, 0f) * avg;
if (transform.position.x > 10.0f)
motion_multiplier = -1.0f;
if (transform.position.x < -10.0f)
motion_multiplier = 1.0f;
}
}
As you can see, I tried VERY hard playing with deltaTimes, LateUpdates, FixUpdates, targetFrameRates and such, NOTHING helps. Also my Build settings do NOT have Debugging Build ON, the VSync is OFF (it doesn’t matter anyway, all VSync settings produce some sort of stuttering). My testing device is HTC One.
I’d really love to hear that Unity team is aware of this and a Fix is coming up SOON, or even better: I’d love to hear that I AM WRONG and someone knows how to help me, because to me, it’s very strange that people don’t talk about this problem at all , so I MIGHT be missing something . Please help me, someone.