Should I use rotate or animation ? ( for performance )
Icebox
Member Posts: 1,485
Hey guys , I have on my level 30 collectable coins , and I was wondering what would be better on performance , to make it unmoveable with animation or to make it moveable with rotate behavior ?
Thanks
Comments
Generally speaking animations are less of a strain on a device's processor than actual physics based moves - but to be sure test it, spawn a hundred actors with an animation applied into a blank scene and play it on your target device - then do the same thing again but swap the animation for a rotate behaviour and see the effect of each on the frame rate - if both play smoothly at 60fps then up the number of actors until either the animate or the rotate version starts to drop the frame rate - in my experience animate usually performs better.
@Socks Thanks alot
Quick test results (I wanted to know the actual answer too):
Tested on iPad Air 2 - using GS 12.10.
The results (at least with the test situation I used) show the two (animate vs rotate) are pretty close, it was actually hard to get enough actors on screen to show up any differences, even at 500 actors all either rotating or animating I was only able to get the frame rate down to ~58fps - so basically there is little difference between the two.
. . . . . . .
130 actors (13 columns by x 10 rows) @ 50 x 50 pixels.
Animation behaviour 25fps / 13 frame loop = 60fps
Rotate 90 @ degrees per second = 60 fps
. . . . . . .
250 actors (25 columns by x 10 rows) @ 50 x 50 pixels.
Animation behaviour 25fps / 13 frame loop = 60fps
Rotate 90 @ degrees per second = 60 fps
. . . . . . .
500 actors (25 columns by x 20 rows) @ 50 x 50 pixels.
Animation behaviour 25fps / 13 frame loop = ~58fps
Rotate 90 @ degrees per second = 60 fps = ~58fps
. . . . . . .
Shock results just in . . . !
Looks like 'animate' might be just in the lead, but you really have to push the project to the very extremes to notice the difference, I crammed a thousand (!!!) actors onto the screen . . .
1,000 actors - rotating = 46 fps
1,000 actors - animating = 48 fps
. . . but to be realistic the difference is fractional, for 30 coins the choice of whether you use animate or rotate will likely have zero effect on performance.
@Socks thank you so much this is really good , I think this forum is one of the best with people like you to help out this way , i really really appreciate it.
thanks
Good information. Thanks for testing and posting.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I've done a lot of these tests, others show a more pronounced advantage to using the animate behaviour over using things like a constrain behaviour - for example constraining an object's opacity so it fades in and out continuously is more demanding on the processor (with all other things being equal) than the same actor using an animation to achieve the same goal.
More surprising results have shown things like the display text behaviour to be surprisingly draining on the processor in certain situations, In all these situations I'd always say test, test and test (and test) ! Throw lots of actors on screen doing A and then lots of actors doing B, this will highlight any performance advantages.