Rotating multiple images continuously (2D) - Mobile performance/optimizations

Hi,

I am experimenting some performance related things on a 2d game for mobile. I am using Unity 5.2 GUI (canvas). I need to rotate 8-10 images simultaneously and continuously on z axis. I tried following code, there was only 1 image on scene and no other code was there. But still the performance was not very good, specially on mobile. On desktop (unity editor) fps was around 80-90 (according to Unity Stats). On android we can see some slight jerks. I don’t want these jerks coming up.

void Update() {
	this.myImage.transform.Rotate(0, 0, 100.0f * Time.deltaTime);
}

I tried using FixedUpdate but there was no difference. On google when searched I found some references doing rotation using Physics (rigidbody2d and torque) but not able to find any useful example of the torque as I am quiet new to physics.

So could anyone please share some ideas on how to implement continuous rotation in mobile with high performance.

What you have there is the simplest way to rotate an image. If you’re seeing hitches, then one of two things are at play:

1.) The GPU on the phone just can’t handle dynamic rendering that well, especially if it’s an older phone.
2.) (more likely) the hitch is coming from somewhere else. You generally can’t assume it’s the rotating image, so you need to profile the program and determine the actual source. Usually, with problems like this, it’s memory management.

I found a similar problem when I rotate an object in the animator and the solution I found was to change the ownership of euler rotation in the interpolation option “euler angle (quaternion approximation)” …
I guess you would have to put something like this in the script …

transform.rotation = Quaternion.Euler (0f, 0f, 30f);

but like I said my problem was similar but the animator … try it and if it’s advised to be clear …
  forgive my English I do not speak English I’m using google translator … :slight_smile: :slight_smile: :slight_smile:

obviously is just the script, you would have to attach to your variables