I'm working in Unity and getting some crazy weird motion behavior. I have a plane and I'm moving it. It's ever so slightly getting about 1 pixel bigger and smaller. It looks like the it's kind of getting squeezed sideways by a pixel. I'm moving a plane by cos and sin so it will spin on the x and z axes. If the planes are moving at Time.time, everything is fine. However, if I put in slower speed multiplier, I get an amazingly weird jerk in my animation. I get it with or without the lerp. How do I fix it? I want it to move very slowly. Is there some sort of invisible grid in unity? Some sort of minimum motion per frame?
I put a visual sample of the behavior here.
Here's the relevant code:
public void spin()
{
for (int i = 0; i < numPlanes; i++ )
{
GameObject g = planes[i] as GameObject;
//alt method
//currentRotation += speed * Time.deltaTime * 100;
//rotation.eulerAngles = new Vector3(0, currentRotation, 0);
//g.transform.position = rotation * rotationRadius;
//sine method
g.GetComponent<PlaneSetup>().pos.x = g.GetComponent<PlaneSetup>().radiusX * (Mathf.Cos((Time.time*speed) + g.GetComponent<PlaneSetup>().startAngle));
g.GetComponent<PlaneSetup>().pos.z = g.GetComponent<PlaneSetup>().radius * Mathf.Sin((Time.time*speed) + g.GetComponent<PlaneSetup>().startAngle);
g.GetComponent<PlaneSetup>().pos.y = g.GetComponent<Transform>().position.y;
////offset
g.GetComponent<PlaneSetup>().pos.z += 20;
g.GetComponent<PlaneSetup>().posLerp.x = Mathf.Lerp(g.transform.position.x,g.GetComponent<PlaneSetup>().pos.x, .5f);
g.GetComponent<PlaneSetup>().posLerp.z = Mathf.Lerp(g.transform.position.z, g.GetComponent<PlaneSetup>().pos.z, .5f);
g.GetComponent<PlaneSetup>().posLerp.y = g.GetComponent<Transform>().position.y;
g.transform.position = g.GetComponent<PlaneSetup>().posLerp;
}
Invoke("spin",0.0f);
}
The full code is on github.
There is literally nothing else going on. I've turned off all other game objects so it's only the 40 planes with a texture2D shader.
I removed it from Invoke and tried it in Update -- still happens. With a set frame rate or not, the same problem occurs.
Tested it in Fixed Update. Same issue.
The script on the individual plane doesn't even have an update function in it. The data on it could functionally live in a struct.
I'm getting between 90 and 123 fps. Going to investigate and test further. I put this in an invoke function to see if I could get around it just occurring in update. There are no physics on these shapes. It's a straight procedural animation.
Limited it to 1 plane - still happens.
Thoughts?
Removed the shader - still happening.