Capto_Capture 2020-07-14_02-36-56_PM
George Rowland

George Rowland

The Resource Dilemma

So far I have been developing and testing on my PC. I dev on a Mac with a 4.2 GHz processor and 64 GB ram. This is a game being created for the Nintendo Switch and mobile devices, neither of which share the resources of my dev box. On my first test run of this game on mobile, it was fun to play but for several reasons ran into problems. In the upcoming posts, I will talk more about these issues.  I will also discuss some of the workarounds I used to increase performance on mobile devices.

The issues I had are listed here and expanded upon later in the article and in future articles.

  1. Mesh Collisions are expensive (especially with overly complex geometry)
  2. Physics are expensive
  3. Object creation the easy way (instantiation vs pooling)
Mesh Collisions

In my attempt to go fast I utilized Unity’s built-in collision polygon collider generation system. I am not bad-mouthing Unity, I love their products, but many of their out of the box solutions are not the most performant choices, especially if your target is mobile. The asteroids are pretty simple sprites, however, Unity decided to turn the spherical items into collision calculation nightmares. To approximate, the shape of each asteroid Unity created hundreds of nodes in the collision mesh. This meant for each physics step it had to determine if a collision happened on a very complex series of shapes. I discovered this issue after testing on my mobile device and not seeing the performance I wanted. I opened the profiler and Physics2D was the top user of resources. I created a script that would optimize the collider shapes but decided to go with a manual node reduction for the final product. I was able to get the asteroids down to a handful of nodes for each asteroid. The ships were an even worse issue. With guns and jagged edges all over the place, the generator had created nodes everywhere. I used the script again to reduce the nodes to a reasonable amount and then cleaned them up manually for the finished product. After these changes, I noticed a frame rate increase and a reduction of heat in my device.

Next week I will tackle the physics issues I created for myself. 


Share this post