android frames per second - how optimize and is it because a phone? - android

I have small game project. It looks fine, works fine, but when I started it today at Android with fps counter - I have just 10 fps o.O
What are ways to optimize? What should I verify?
My app have:
menu panel with two buttons
game panel with view from phone camera
some other panels with some graphics/buttons (never more than 5 per panel)
No animation, no complicated scripts. At my computer it has about 60 fps.
I'm doing it in Unity3D.
I'm using NGUI+tk2d, I have one/two drawcalls per panel. I'm disabling panels which aren't using.
I'm not using Update function to often - just for "fps counter" and... that's all.
I'm using atlases for all graphics.
So - what more should I verify? I'm really confused. Can it be because of my phone have something wrong with system? Or it's problem with app?
I will be really grateful for your suggestions.

Related

problem with exporting a game to android in unity

I created a trial 2D game in unity which consists of 4 scenes. In each scene there are several objects. Generally game is not very demanding in terms of components. The problem is exporting the game to android. The application stutters a lot as if it had 5 fps and the graphics deteriorates significantly. I tried to export the application to my computer and the game does not stutter but there are slight blurring of objects in addition I noticed that when I turn on the game the computer starts to howl, I checked what is the reason and it turned out that the application consumes all the graphics prosesor I do not know why. In the application (on android) were also strange errors among other things when scaling the buttons in the menu (they are very small) and the animation of loading the scene (also very small does not cover the entire area). It is possible that it is about "player settings" but I am not sure.
I am focusing more on android so this is the problem I would like to solve the most.

UNITY: How to make the UNITY preview look like an android portrait

I usually develope apps for android with visual studio, but i want to increase my programming knowledge a little and am trying into game development.
I watched some tutorials and get everything to debug on my phone, but I have one major question ahead of me, before I can really start:
So, in Visual Studio I usually deliever 5 different hdpi folders, and work with linearlayouts and set weights which work as some form of percentage towards the users screen. With this technique, the apps that I build usually look more or less the same on every android device out there (which indeed are LOT).
If I come to unity now, I'd like to set the preview window of my mobile game to already be in a portrait format. Which would be some kind of 90 degree 16:9 ratio. I can bring it to 16:9 ratio but, again this is always landscape and never portrait. But that means that I kind of need to guess what the game will look like when finished - and that is a no go!
So how could I achieve what I need? Sort of tilt the 16:9 ratio over by 90 degrees.
I hope I made myself clear!
Thank you!
Okay thanks, I kinda found a way just by playing around with it.
Where it said "16:9" right above the preview screen. When clicking on it and then clicking on this little "+" i could manually provide a resolution such as 1440 x 2560. This brought it into portrait android mode. THANKS :)

How to migrate from flash to adobe air iOs and android?

I have a few projects with flash that i'd like to turn into apps for mobiles, I started reading adobe air and i've noticed that it uses back some things like inframe action script, something that I have not done since as2.
Is there a way to load scripts and classes like a normal flash file?
If I have a noncomplicated swf, is there a way to migrate it easily into adobe air for android and iOs?.
I've been struggling to find examples of adobe air projects, does anyone have a tip for this?
It is easy. I have converted 30 games to run on iOS and Android. The biggest problem was that they were in AS2 and had to be converted to AS3 first. If your uncomplicated swf projects are in AS3, and developed using Flash Pro, then just change the publishing output from swf for a web page to iOS pr Android. Android would be easier to start because you don't need to get an Apple developer account, create a certificate and provisioning file. With Android you can create a certificate right in Flash Pro. You test publish on your pc or mac first. When you are ready to test on a device you create an ipa (iOS) or .apk (Android).
Yes, there are a lot of screen sizes out there. But you know how you can create Flash in a web page so that it will resize with the page and keep its aspect ratio? Well its the same on mobile - it will resize to fit whatever mobile screen it displays on. Most likely your game is in landscape orientation. Just keep it that way and test it on whatever device you have (an iPad would be good because that aspect ratio or 1024 x 768). Actually, we kept the stage to 736 x 552 and that fit on any screen out there. On tall (wide) screens like the iPhone 5 & 6 you will have space on the sides, but so what.
Just give it a shot and you'll see how easy it is to write an app for both platforms at the same time. And you don't even have to own a Mac (you only need one to upload your completed app to the store, but you can rent time on one and log into it for 10 minutes to do that.)
There's no "how to" when porting a Flash project to Ios or Android. It's the same technology so it's compatible in theory. You can simply compile and publish and you'll get a Ios and Android app in most cases. Now there's 3 major problems that probably 100% of Flash projects will face when publishing for mobile and in probably 99% of cases those problems might imply recreating the whole thing from scratch.
First problem: Sizing and Density. So many phones/tablets sizes and density, chances are your Flash project doesn't have a single line of code dealing with that and as a result your app won't display correctly across any mobile devices. You'll have to put together a big piece of code to handle that and make sure it doesn't break anything in the original project. Good Luck with that.
Second Problem: Performance and memory management, I'm yet to see a Flash project that doesn't systematically waste CPU and memory constantly. That's no problem for a Flash project except when publishing for mobile: can we still waste CPU power? NO, can we still waste memory: NO. You'll have to go through your entire Flash project and optimize everything to not waste CPU and memory. Once again Good Luck with that.
Third Problem: assets. Did you use a bunch of MovieClip here and there? Well no more on mobile unless you want your app to lag and drain the battery down and make the user experience as bad as possible. All assets have to be optimized for mobile, the right asset, the right type, the right size or else ... lag and bad experience. Here again Good Luck with that.
And this is just a small run down of the problems you'll be facing. You will spend probably hundreds of hours trying to port that Flash project to mobile and at the end it will still be running bad anyway. Chances are you should just start over.
EDIT:
Simple Guidelines:
render mode: usually "gpu" (very efficient with bitmap) but "cpu" is also possible (you get more CPU power but less bitmap display efficiency) and also "direct" if you want to use Stage3D (more complicated).
Display: usually bitmap and only rarely vector. Don't oversize them and don't undersize them either. Reuse as much as possible (saves memory and battery)
Handling sizes and density: scaling your content is the easy way but not the less efficient one, as long as your bitmaps are of good quality you should be able to get a good resolution in most density and size. Because there's so many different sizes out there you'll decide if you want your content to fit any size or to display as much as possible while filling the side gaps. AIR/Flash has no built-in system for handling that so you'll have to create your own or to find something open source out there that can do that. Basically you have a content that is n x n and it needs to display on a mobile screen that is n x n, you calculate the scale factor and scale your content and center it.
perf, memory, battery: reuse object as much as possible. If there's a bitmap that you'll use often don't get rid of it just reuse it. If you reuse you don't need more CPU, don't need more memory and don't need more battery.
how to get perf: displaying something and running code, that's the 2 things that will slow down the app so optimize both and test often. Maybe reducing the quality of some bitmap will boost your perf. maybe optimizing your code in some places will get you a few more fps, etc. This is a per project try and test.

Unity android weird build behaviour

I am currently working on an android game in Unity. In the editor everything looks great, actor moves smoothly, generated dungeon looks nice. After building the game and start it on my smartphone the whole dungeon looks different and when moving my actor I can notice strange vibration that has never appeared before. While vibration my be caused by "wrong" implementation(I am working on very powerful Desktop so the code may be not optimal), the strange arrangement of dungeon is not about implementation at all. I tried building same version on web player and it looks jut as in editor. Look at the differences between Android-Standalone builds.
Android: http://imageshack.com/a/img901/5057/7REtUn.png
Standalone: http://imageshack.com/a/img661/2618/2Em05d.png
As you can see standalone build is just as expected, nice corridors and chambers, while on android... chaos?
EDIT: While using Unity Remote everything looks fine. Well movement isn't okay but as I said am sure now it is caused by implementation. But generated dungeon keeps unsolved.
Have you tried adjusting your targeted frame rate? Maybe your targeted frame rate is set improperly for your specific device. You may also want to try lowering the native resolution . If your resolution is really high it will cause choppiness and lag. Another item I also had to tweak to get my game to run well is the Lighting Options. From forward lighting you can change to vertex lit and it substantially speeds things up.
You may also want to mess with your shaders a bit, and see what mobile options you can go for. Various shaders have different outcomes, also rendering paths effect how things look. Are you using OpenGLS 2.0, 3.0, specifically look the settings from standalone to mobile in Player Settings.
Also make sure you're using the new Unity Remote as opposed to the old version. The old version works through wifi which is slow, the new one uses tethered USB and is relatively well.
To adjust the screen resolution as I mentioned above I had to:
75% resolution (landscape):
Screen.SetResolution (Screen.width * 0.75f, Screen.height * 0.75f, true);
To adjust target framerate as mentioned above:
Application.targetFrameRate = 60; //sets framerate to 60.

Video on canvas with panning - how to solve performance issues (also: HTML5, Flash or something else?)

Long version:
I have a very particular issue. I'm a multimedia artist working at the moment together with an animator - we are trying to create an interactive animation that I want to make available online as a website and as free app on the App Store and the Android Market.
But here's the key problem I am faced with now.
The output video of the actual animation will be massive in resolution - probably something like 4 or more times the HD resolution, but it's for a reason. The idea is to let the viewer only watch a part of the video at one time - like when panning around in Google Maps or any other canvas-like view (eg. MMORPG or strategy computer games). So you only see a part of the whole image at one time, and then you can move around to see what's "behind the corner".
So the animation would be a Google Maps-alike canvas (panning and perhaps zooming if there's enough time to implement it) but with video instead of images.
The big problem that comes up is performance. I was thinking that the best way to make it run would be to scale down the video for different devices accordingly. But then even just considering desktop computers for now - scaling down to 720p for HD screen means there is in total of about 4 times 720p in resolution, which is probably too much for an average computer to decode (Full HD is quite often already problematic) - and the output resolution would be more than the 4K standard (5120 by 2880, whilst 4K is 4096x2160). Anyhow, that is unacceptable.
But I reached the conclusion that there is really no point in decoding and rendering the parts of the video which are invisible to the user anyway (why waste the CPU+GPU time for that) - since we know that only about 1/6th of the full canvas would be visible at any given time.
This inspired an idea that maybe I could split the output video into blocks - something between 8 to 64 files stacked together side by side like cells in a table, then have a timecode timer playing in some variable and enabling the video-blocks on demand. As the user drags the canvas to the visible element it would automatically start the playback of the file at the given timecode read from the global variable. There could be some heuristics anticipating users movement and prematurely activating the invisible blocks in order to remove any delay caused by seeking within video and starting the playback. Then blocks which are no longer visible could deactivate themselves after a certain amount of time.
So my first attempt was to try and see what are my choices platform-wise and I really see it comes down to:
HTML5 with JavaScript (heavily using <video> tag)
Adobe Flash (using Flash Builder to deploy the apps to all the different devices)
And HTML5 would really be more preferable.
So I did some research to see if it would be at all possible to even synchronize more than one video at a time in HTML5. Unfortunately it's far from perfect, there are two available "hacks" which work well with Firefox, but are buggy in Webkit (the videos often get out of sync by more than a few frames, sometimes even up to half a second, which would be quite visible if it was a single video split into blocks/segments). Not to mention the fact that I have not even tried it on mobile platforms (Android / iOS).
These two methods/hacks are Rick Waldron's sync as shown here:
http://weblog.bocoup.com/html5-video-synchronizing-playback-of-two-videos/
And the other one, also developed by Rick is the mediagroup.js (this one doesn't work in Chrome at all):
https://github.com/rwldrn/mediagroup.js
My test here: http://jsfiddle.net/NIXin/EQbAx/10/
(I've hidden the controller, cause it is always playing back earlier than the rest of the clips for some reason)
So after explaining all that I would really appreciate any feedback from you guys - what would be the best way of solving this problem and on which platform. Is HTML5 mature enough?
Short version:
If I still haven't made it clear as to what I need - think of a video zoomed in at 600% so that you can't see everything (some bits are off screen) and you need to pan around by dragging with your mouse (or flicking your finger on mobile devices) to see what's going on in different places of the video. How could I do that (have the video run smoothly) across platforms, while retaining the high quality and resolution of the video?
Thanks a lot, let me know if you need any more details or any clarification of the matter.

Categories

Resources