playMaker

Author Topic: iOS/Android 101  (Read 10538 times)

Sjones

  • Full Member
  • ***
  • Posts: 203
iOS/Android 101
« on: May 01, 2013, 04:05:38 AM »
iOS / Android 101

Many people ask a lot of questions about the mobile platform and how to do things within playmaker.

So I thought I would make this outline to answer all the most common questions.

If people have any other common question I have missed post a message and I will look into how common it is and an answer - this is not a post for every question about iOS and android.

First of all I want to put Playmaker into perspective here, playmaker (with some exceptions) extends only what unity comes with (there are other add-ons - actions - but those are related to those plugins and I will not be focusing on them here, only playmaker and unity)

Before I start, please watch all the playmaker tutorials provided for free, they are excellent and even though some of them are not related to mobile development, their setups, actions and implementations can be used on any platform

http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

so down to business.
Q. How do I implement this control scheme or that control scheme, including tapping, sliding and / or gestures.

A. Unity itself does not have any gesture controls built in to it - as such playmaker doesnt either - to do any gesture control including swipe, pinch etc you will either need to buy a plugin that is supported by playmaker with actions OR use the unity functions of touch event and touch info - these will give you any touch event and then once touched the info about that touch - you then use this in mathematical equations (rect to test if it is in an area of the screen or sqr root of the 2 fingers for distance e.g. zoom) to calculate the gestures.


Q. I am using Unity GUI how do I....

A. I strongly recommend using anything but the built in GUI for iOS or android - if you can afford the mobile license invest in a bit more with something like nGui - the unity GUI is too expensive for mobile platforms - if you want to research into why search for draw calls - but the basics of it is the original ipad could handle ~25 draw calls and each GUI element = 1 draw call. Apart from this it is limiting that they don't recognize ontouch and the texture and animation options.


Q. How do I tap to get, tap to drag or tap to interact

A. This again is to do with touch info and Screen Pick, you can save the object you touch with the raycast (from within the actions) and collision around that object - do tests like did it touch object - yes do something - no do something else, to move something store the game object and then pass the position from the touch info to the object position itself - you can also filter by layers to help with touching an object or not - or a specific set of objects.


Q. How do I control the camera with touch.

A. again use the touch info - either the position or the delta - if you want it to orbit - set an iTween with a look at target and rotational info - remember to have every frame active on the state to constantly update.


Q. My game is laggy, unresponsive or slow.

A. This will be performance issues, the main things to look out for.

   Draw calls - this eats cpu time up - the less the better - combine meshes together and don't use the unity GUI

   Shaders - if you don't know much about shaders always use the mobile shaders provided by unity

   Shaders Advanced - Don't use multiple pass shaders

   Polycount - make sure you have not got too many polygons in the scene at any one time - also make sure your 3D objects are not too high poly count - large polycount meshes slow the rendering time down - at this point its better to have several smaller meshes

   Lights - always have your lights baked for mobile - real time / dynamic lights are very expensive

   Physics - don't use too many physics at any one time, this will also eat into cpu time - set to is trigger if you don't want the physics engine to calculate that collision mesh (ray trace and trigger event should both work still)

   Textures - do not have too many texture - this is going to be the least bottle neck nowadays as most phones have a fair amount of memory for textures - but doesn't mean you can go mad.

   Playmaker - having too many active playmaker FSM's can slow the game down - think about what needs to be run separately and what can be combined into a single large FSM.


Through my experience of playmaker - I have notices in my game that the following actions are used the most in combination with others though - I have kept them to the most relevent to mobile - I have udes many more but this is more to do with the type of game rather than the platform - though these are not limited to iOS or android.

Get touch Count
Get Touch Info
Touch Event
Activate Game Object
Add Component
Create Object - Caution this is expensive - I have used it in menus where the lag spike is not noticable
Destroy Component
DestroySelf
Set Game Objetc
ScreenPick
iTween Move To
iTween Scale To
Set Material
Next Frame Event
Send Event
Get Position
Set Position
Set Property (used a total of over 800 times in my game)

P.S. - I have posted it here in the iOS section as iOS is more popular - if the forum admins think this is useful then it can also be posted in the android sub forum. - but for now I do not want to double post / spam the forums.
« Last Edit: May 01, 2013, 04:10:03 AM by Sjones »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: iOS/Android 101
« Reply #1 on: May 01, 2013, 04:44:50 AM »
I have a bunch I could add to this when im at my computer but just one note from my experience - do not create objects at runtime on ios/android! The spike you mentioned is the garbage collector. Use array maker to create a pool of objects or get pool maker.


coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: iOS/Android 101
« Reply #2 on: September 24, 2014, 05:11:34 PM »
any more tips? these are great! thanks