Hi All
After a year of intense frustration and reading posts from you all I have managed to get to the bottom of why my objects had a stutter when moved across the screen.
Why am I posting this?
Well, during my travels through the Unity posts, I noticed that I am/was not alone with this problem, so if this helps others then it is worth the time to write this post.
So first what was the problem?
In editor and in final build, objects would have a jolt in movement every few seconds.
The camera is fixed with a script on the moving object such as …
var Speed = -4.0;
var DestoyObjectTime : float = 6.0;
private var blockFlag = true;
function Start()
{
yield WaitForSeconds(1);
}
function FixedUpdate ()
{
if (blockFlag)
{
DestroyTimer();// start destroy timer
}
}
function Update ()
{
if (GameObject.Find(“DieFlag”) !=null)
transform.position += transform.forward * Time.deltaTime * Speed; //move transform
}
function DestroyTimer()
{
blockFlag = false;
yield WaitForSeconds(DestoyObjectTime);
if (GameObject.Find(“DieFlag”) !=null)
{
Destroy (gameObject);
}
}
The object (with this script attached) is spawned from another script, hence the find commands for reference to the mortality of the main character. You can see the function update is very simple and consistent in its routine timing.
Still I had this stutter/jerk in the movement, I tried it on two Macs and two PC’s and in build on all iPhones and iPads, still the same problem, I tried every combination of Update functions and played with deltaTime, I reduced my moving objects to no textures, but yes still the same problem.
I have two games in the very final testing stages but this problem was stopping the release and the fact that I have to go pro version next week.
How did I find and sort the problem…
A few days ago I thought that it is time to go pro and I don’t mean walking the streets at night.
I had read about the Profiler option and thought that I would give it a try.
This showed a spike every time that the spawned object (the one with the above code attached) was instantiated into the scene.
It showed 94% every couple of seconds and peaks matched to the timing of the jolt in movement.
The 94% was showing on the BAKE SCALED MESH PHYSX COLLISION DATA. without the pro version trial I would have never known this.
I then searched the net and found Gshape Games (Thank you) and there it was the answer:p
1, “Having an object with a mesh collider scaled at something other than <1, 1, 1>”.
2, “Moving an object that is marked STATIC”
3, “Moving object with a mesh collider that is not marked CONVEX”
In my case 1 and 2 were the case.
When you import the fbx and tick the collider option it puts on a mesh collider and leaves the convex option un selected.
I corrected the above with all my spawned objects by changing the colliders to other types due to all of my objects being scaled after imported.
Beware the problem still looks the same in editor but in builds on all devices it was fantastic not one jerk,stutter or jolt FANTASTIC
Just these 3 simple rules and the transformation is chalk and cheese.
All I need to do now is pay for Unity Pro and the games will be on the app store before Christmas.
Merry Christmas to you all and I hope that this post helps others with the same frustration.
iPhone Deano