Tag Archives for unity

Iceland, what a beautiful piece of rock! The island was one of my dream places to visit since I was a young boy, due to many areas of my personal interests covering: geology, volcanoes, nature, ice, astronomy, a lot of Science and the sense of adventure. Iceland has it all. Although, this trip was my second visit I definitely didn’t have the same experience first time.

Where to begin?!

I’ll start with my actual reason for visiting and this was for an interactive media conference focusing on Virtual Reality called Slush Play.

Representing Unity, my role at the conference was to catch up with the local game development scene (which is on a steady rise), meet new contacts from different industries and companies and continue sharing my knowledge and learning more about Virtual Reality, all achieved I must say.

The event was one of my favourite experiences at a conference and I have attended many. I only stayed for the one day, missing the second day of the conference but the time I spent there I had many productive and interesting discussions with new and known people, everyone I met we seemed to get on and have a laugh which isn’t always the case at conferences, it felt like everyone was there for the same reason and objective.

Blue Lagoon:

On arrival, I went straight to the Blue Lagoon, from the airport it is surprisingly close, 15-20 minute drive, the general advice is to go after or before flying due to the proximity.

I find it a little hard to describe my feelings towards the Blue Lagoon, I was excited to be visiting and I actually feel a bit disappointed post visit but I believe this to be because my expectations leading up to the visit were wrong.

My vision for the Blue Lagoon was no way near what it actually is, this might sound a bIt silly as I had read about it online via reviews and other blog posts and the official website of course. I thought, what I would be swimming in was something that hadn’t been so man made and crafted, I thought it would be more natural (I wonder if anyone reading this knows what I mean?), the whole site is heavily crafted for what I imagine is safety reasons, I mean we are technically swimming in a big bath that is being heated by geothermal energy.

There isn’t much to do when you get there, it is basically you taking a very long bath, in a big bath, outside, with other people in it. Before you reach the bathing areas you would need to navigate through all the naked people (men in my case), it is a requirement that you shower without your swimwear on, this is for hygienic reasons. Luckily there are one or two private showers.

There’s a bar which you can swim up to, expensive drinks obviously, alcohol is on sale. There’s another bar which serves silica mud masks, which you can apply on your face and leave for 10-15 minutes then wash off. After, you can apply an algae mask for moisturising your face.

Once you’ve had fun spreading mud and algae on your face, I just tried to make the most of what was on offer, so I bathed and practiced some meditation techniques I’m learning, actually this was very nice and relaxing, I felt rejuvenated, energised by the natural surroundings and soaking up all the healthy minerals and goodness in the sea water.

I would recommend visiting the Blue Lagoon, please don’t be put off by my comments, I don’t regret going at all, the average time someone spends there is 2-3 hours, this seems about right, I wouldn’t take a day out of my trip to do this again, it definitely makes sense to do it on the same day as flying. I probably wouldn’t go out of my way to go a second time. I actually buy the silica mud mask and other products online.

Excursion day:

The second day in Iceland was the speakers excursion day, I wasn’t a speaker but I got to attend in place of my colleague who was speaking but was arriving on the day of the excursion.

The excursion consisted of a 2-3 hour drive to a Glacier, which we would then drive snow mobiles on, are you fucking serious? Snow mobiles? Me driving? On a Glacier?! Yes they were serious, adrenaline rush coming up.

Before the rush, we stopped for a break, which happened to be the site of one of Iceland’s famous Geysir’s, I had the pleasure to witness the power of a rare hydrogeological condition, which is only possible in a few areas on Earth which are near active volcanic areas, Geysir’s happen because they are near Magma. It is interesting to know you are standing relatively close above Magma..

What a beautiful site, great to witness the power and energy planet Earth showcases in the form of a Geysir.

Snow Mobiles:

I’ve always wanted to see a Glacier, huge powerful blocks of ice that shape and cut the rock beneath it, this seemed quite a scary thing to do, knowing about how cracks and deep crevices form on Glaciers, what happens if there is a crack opening and I drove into it?! Well, I wouldn’t be coming back that is for sure, that fear of driving on ice that’s slowly moving down a rocky mountain sounds a little crazy, I have experienced other extreme sports before, jumping out of a plane at 15,000ft to name some, but this actually felt like a step up from that believe it or not. All I could do is embrace it, so I did, I’m not one to shy away from doing something new, whether I would do that thing again is another matter.

When we arrived at the Glacier there is a hut where the crew hang out who organise the excursion, we also had a nice warm hotdog to get an energy boost to prepare us for what was about to happen, the hut is very close to the Glacier, it is right there, a huge mountain of ice just sitting looking quite menacing, I was thinking I’ll be driving a snow mobile on that shortly, is this actually happening? Am I dreaming?!

Soon after, we started suiting up, the only time I would ever wear a onesie is for extreme sports, this onesie was incredibly thick and warm, designed to be placed on top of the already warm clothes I was previously advised to wear. I also wore a helmet that was thicker than any other helmet I’d ever seen, it almost felt like I was gearing up to go to space or something, but what I did know is that I will be going to quite an inhospitable place which is extremely dangerous.

I hopped into the super jeep, this was the first challenge, the drive had to take us over the bed of rocks, it looked like something from Mars, this was off road at it’s finest, driving extremely slowly so we didn’t tip over, we were told to keep our helmets on inside the vehicle and to try to avoid head butting the glass windows. This short drive took 15-20 minutes to reach the base of the Glacier.

We drove up the Glacier to meet the nutters who regularly drive snow mobiles on Glaciers, oh, I mean these totally sane people who would no doubt teach us how to drive one. To my surprise the safety instructions took no more than 60 seconds, keep your feet inside the vehicle, that’s the throttle, that’s the break, don’t break while using the throttle. Okay?! ready?! Uhmmm okay, hey why not, remember let’s embrace it, so I picked my snow mobile, obviously trying to pick the most awesome looking one, there were different colours and design variations, some cleaner than others but all do the same thing..I hope.

Driving the snow mobile is definitely more challenging then I thought it would be, the throttle was almost like a side angled Xbox controller trigger but in a position for your thumb to use as if you were changing gears on a bicycle. This made it particularly challenging to maintain your speed while turning left or right, you also had to lean into the turnings as weight distribution is super important on that type of terrain. The terrain is very bumpy, uneven, icy and generally treacherous and the trails left from other snow mobiles tend to off balance and redirect you slightly.

All is going so well, I’ve got the hang of it and I actually got some air time in one instance (not sure how many points I got for that), standing up as well, I was also going quite fast up the slopes.

No, it wasn’t going as well as I thought, maybe I got a little complacent? I crashed!! It wasn’t a crash into something, the snow mobile decided to throw me off to the side and it flipped over, it was actually all my fault, I didn’t lean into the turning properly and the slope on the turning was steeper than I anticipated, weight distribution wasn’t correct and it chucked me off, luckily I knew it was coming, so I partly jumped out of it and landed as comfortably as I could, otherwise that 300kg snow mobile would of landed on my right leg crushing it between the vehicle and hard ice layered on top of hard rock, that would not of been fun I promise. I picked myself up instantly, my heart was racing and adrenaline was rushing around my body, it is actually quite important that I checked myself over properly, adrenaline can mask any pain you might have, I was a little worried that I may have broke my wrist as this was what I primarily used to land on, of course this is never recommended but it’s such a natural thing to do, silly human brain.

Turned out I trashed the cool snow mobile I picked, it’s now out of action, so one of the sane guys picked me up in his snow mobile and we were already heading back down the Glacier as the excursion was coming to an end. Luckily I got to hop off and drive another snow mobile down the Glacier for the final descent, obviously a little nervous to get back on one on my own, but if you fall off you should definitely get back on, best to conquer that fear now then letting it brew until the next time I get to drive a snow mobile.

Snow mobiles over, we were treated to a BBQ back at the hut, the meat was cooked to perfection and the veggies and salads were delicious, food in Iceland is incredible, so fresh and healthy it’s a dream.

On the way back to Reykjavik, the organiser from Slush announced on the super jeep minibus that we are stopping for a waterfall break, naturally I thought that was a metaphor for a toilet break, to my surprise it wasn’t, there’s an actual waterfall, another incredible surprise Iceland has thrown at me, driving up to the sight I had absolutely no idea there was a waterfall in the surrounding area, the flat rocky lava planes go for as far as the eye can see, the waterfall cut down into the terrain, it’s a glorious feature, it was my first time seeing a waterfall of this magnitude, it was magical.

Killer Shark:

In the evening I went for dinner in the center of Reykjavik, serving traditional Icelandic food…fish. This is where I experienced the delight that is Killer Shark, in Icelandic it is called Kæstur hákarl, pronunciation TBD.

It is fermented Shark, the Shark has been fermented for 5-6 months because the flesh is poisonous. The Shark is called Greenland Shark.

The Shark was presented in a Jar, two small cubes of flesh were inside, I opened the jar and took a whiff and it stunk of ammonia, whoa that was rather off putting. The topic of the day seemed to be about “experiencing new things”, so I wasn’t not going to try it now, I tasted the one of the two pieces of flesh, very fishy taste at first then this horrific ammonia after taste hits, quite overpowering. This type of food is really not my cup of tea. I did eat the last piece if you wondered…

Aurora Borealis (Northern Lights):

It seemed like Iceland was throwing everything at me in just one day, there was a buzz throughout with the locals as there was a predicted spectacular showing from the Aurora Borealis in the evening. Reykjavik was to turn their city lights out from 10-11pm for Astronomy. This was so awesome and I hope other cities around the world take notice and do the same, light pollution is such as issue especially in the UK and it is a shame we are blinded from this in order to see what would be a beautiful nights sky above us. I took this image with my mobile phone, excuse the quality:

Before falling asleep I had realised I had seen H2o in all 3 of it’s natural states throughout the day, Steam from the Geysir, Ice from the Glacier and water from the waterfall.

If all this wasn’t enough, for the 3+ days in the back of my mind the monster volcano known as Katla was clearing her throat, with multiple earthquakes detected in the area, I didn’t actually feel any earthquake from within Reykjavik but there was and still is a genuine concern that an eruption is imminent and it is predicted to be 10x more explosive than the famous 2010 eruption from Eyjafjallajökull.

In general what an incredible life experience, which I’m so happy to have survived, hope you have enjoyed this post. Now go visit Iceland.

Web deployment with Unity has took a hit in recent months due to the deprecation of NPAPI plugins in Chrome, which mean’t the WebPlayer plugin has been disabled. All major browser vendors are moving away from plugins.

Current solution is to look at the WebGL build target which came in a Preview state with Unity’s 5.0 release. We know there’s some challenges with supporting WebGL right now, but let me detail what the future should look like.

Why Preview?

WebGL now, is in Preview, it’s a way of Unity saying that some functionality and development needs to happen before they consider it a fully released product. Missing functionality from Unity’s side includes:

WebAssembly which allows for taking ASM.js and turning it into byte code, in turn this makes things faster as byte code is faster to parse than JavaScript as well as being faster to execute. This will solve slow load times and slow downloads, also fixing up some memory usage issues.

Data Compression; Slightly self-explanatory, will allow for data to be kept in a compressed format in memory. Currently you need to handle this yourself, but not for much longer. This will greatly help with build sizes.

Shared Array Buffers is a feature that will allow for memory to be shared across web workers, using this Unity can map their current multi-threaded code to JavaScript, so WebGL can benefit from multi-threaded features such as PhysX. No more colliding on the main thread!

WebGL 2.0 – WebGL to become a graphic powerhouse, no really it can. Currently WebGL is using OpenGLES 2.0, remember those good old smartphones?! With WebGL 2.0 Unity WebGL gets the much needed bump up to OpenGLES 3.0, allowing for Unity to lift it’s restrictions on shaders, so we can have image effects (all the bloom you need), deferred rendering, skinning on the GPU. Unity’s 5.2 release included support for WebGL 2.0 as an experimental option, reason; because no major browser vendor has shipped support for it yet as of the date of this post, but you can try with a Firefox nightly build.

Some WebGL tips ‘n’ tricks:

Need to ship projects now with WebGL? Be sure to have taken note of what features in Unity that isn’t supported right now (see above) and also make use of these:

Crunched Texture Compression

You can use this feature as a texture format for JPEG like compression ratio and quality, however unlike JPEG it will directly decompress into DXT, so you have compressed textures on the GPU, no loss in GPU memory, happy days! This feature helps with memory reduction and keeping the data size down.

AssetBundles

A must use for any Unity project really, but for WebGL it will greatly help with a reduction in memory and build size. Let’s reduce everything!

Unity Profiler

If you’re not making use of Unity’s Profiler then you’re doing it wrong, as with any Unity project profile away, it’s fun and a great way of finding your bottlenecks. You should be optimising for WebGL as you do for any other platform in Unity, there’s a lot of resources online for optimising.

WebGL Memory Size

Within Unity -> Player Settings -> Publishing Settings you can specify how much memory (in MB) the content should allocate for it’s heap. If it’s too low you will get out of memory errors, but if it’s too high your content might fail to load in some browsers or on some machines, because the browser might not have enough available memory to allocate the requested heap size. Test and find the correct solution for your app. Optimising your app as much as possible will help with memory reduction therefore the need for a high heap size decreases..

Multiplayer Gaming

Use UNET in 5.1+ as this will work out of the box as it’s using the WebSocket API – you can also write JavaScript code to directly use WebSockets yourself.

Unity 5 has implemented a HUGE update on the rendering / graphics side of the engine, introducing new lighting workflows with realtime GI, a Physically Correct Shader (Metallic & Specular workflows supported) among many other things..

I wanted to do an experiment today, where I test out HDR Skybox’s in Unity 5 to see how drastically the lighting and mood of a scene can change.

HDR:

High-Dynamic-Range is an imaging photography technique to produce a higher dynamic range of brightness. This is achieved by capturing different exposures of your chosen subject matter and combining them into one image.

In Unity we can use these HDR images to help blend 3D models into the environment, this can drastically add to the belief that the 3D model is actually in the environment.

I’ll be showing how these 3 HDR images help create a completely different feel and look to the scene:

I have daytime, evening and night-time HDR’s, they should all create drastically different lighting conditions in Unity.

Time’s up chumps..let’s do this:

Unity 5’s new standard shader has built-in support for image based lighting (IBL), this really helps with the belief that the 3D model is in the environment I am setting with the HDR skybox.

Here’s the model with just Unity 5’s current default procedural skybox:

With a bit of trickery (not really, just pushing a few buttons in Unity), let’s now see what happens when I add the daytime HDR Skybox:

I haven’t messed with any lights at all, all I have is the default Directional Light in the scene with default settings. looks rather impressive after just adding a new HDR Skybox to the scene.

Let’s try the evening HDR Skybox now:

Awesome, I am really enjoying playing around with this, I love how quickly I can completely change the lighting conditions which in turn drastically changes the mood and atmosphere in the scene. I can’t wait to see how games are going to utilize these new features.

Okay, last one, the night-time HDR Skybox, I’m a little skeptical about this one, I’ve no idea how this will look and I imagine it’s not really desirable to use a night-time HDR image. Anyway, let’s see what it looks like:

Actually turned out rather well, the image doesn’t show the white spots on the model as much as in the editor, these white spots are produced by the specular smoothness on the Standard Shader, i.e the more smooth I make it the more white spot artifacts are produced, not sure why this is more present in the night-time scene, I’m sure there’s a setting I’ve missed or something..

Overall, I’m really impressed with this, especially how quickly I can change the mood and lighting of the scene and the visual output from Unity 5’s new rendering / graphics update.

My job is based on supporting Unity’s customer base in the EMEA region, to do a good job that means I need to learn all of the Unity things, features and new services, at least on a high level.

I tend to experiment a lot with Unity’s new features, today I wanted to share with you some of my R&D with Unity 5’s new Graphics overhall, this includes the new Physical Based Shader, Realtime Global Illumination and the new Scene Render Settings.

My experiments are usually aimed at producing a small scaled demo that can squeeze in as many features as possible, this enables me to demonstrate these features easily to customers while in the field.

PBS (Physically Based Shader):

Unity’s new Physically Based Shader a.k.a one shader to rule them all a.k.a standard shader (actual name) allows us to create materials for a wide range of natural surfaces such as Metals, Dielectrics (non-metals): monolithic materials = rock, water, plastic ceramic, wood, glass etc..cloth and organic.

The new PBS also plays nice with IBL (Image Based Lighting), we can setup a skybox cubemap in the new Scene Render Settings to help with really blending our objects into the surrounding environments:

One demo (not developed by me) shows a nice range of different surfaces used by the new standard shader in Unity 5:

We can see there’s at least six different surfaces represented here with the usage of just one shader – Ceramic, Cloth, Metal, Glass, Rock and Wood. The Scene Render Settings really help blending the Doll model into the surrounding area, helping us believe that the Doll is in the Forest environment.

The new shader includes many different texture slots, allowing you to add really nice detail to models. The shader includes a multi-variation of smaller shaders with versions for mobile and high-end.

Our built-in shader code is always available for download and currently with Unity 5 this will include the new standard shader as well – Could change but I doubt it.

Geometry needs to be marked lightmap static but you can relight geometry using Light Probes that are updated in realtime with the GI generated from the static geometry. In my little demo I’ve combined the usage of Realtime GI, PBS, Reflection Probes and Light Probes, the majority of the objects marked as static apart from a few props which demonstrate the usage of Light Probes for non-static objects:

Couple of shout outs, I’ve used the Medieval Assets Pack by Naresh and the Medieval Boat from Mr Necturus which are available on the Asset Store for most of the props. The wooden cottage model center piece is a free model from some site I can’t remember.

Here’s a Vine I recently sent out, little outdated comparing to the above screenshots, but demonstrates the realtime GI in editor with play mode on:

There’s more of this to learn as Unity 5 develops through the beta stage. Note: Screenshots from beta version of Unity 5 – May look different when released.

Everyone has their own workflow and choice of Scripting IDE, but if you’re one of those using MonoDevelop with Unity this blog post should help with an increase in efficiency when working with it..

I’m using a Mac and so the workflow improvements will be based on using MonoDevelop on a Mac.

Syntax Highlighting is important for writing and reading code, MonoDevelop makes it easy to change this, simply click on MonoDevelop-Unity menu item and then click Preferences, the Preferences window will open, there’s a menu on the left hand side, under Text Editor -> Select Syntax Highlighting there will appear eight options for you to chose from. My preference is called Oblivion but pick and test one for yourself which suits you best. You can also enable semantic highlighting which helps with reading code. Use cmd + / – to zoom in and out, so you can see the code you are writing.

Keyboard shortcuts:

Who doesn’t like a good keyboard shortcut, yes there’s many to remember from many different software packages we use, but I think it’s important to have a few for each package that are your most important to your workflow. So here’s a few I feel worth highlighting for an increased workflow:

cmd + return / enter = This starts debugging mode from the Run menu item, no need to go through menu items

cmd + \ = Toggles breakpoint, no need to go through the Run menu item

cmd + shift + I = Step Into, no need to go through the Run menu item

cmd + shift + O = Step Over

cmd + shift + U = Step Out

Other useful actions, “Attach to Process” and “Detach” when debugging Unity, these don’t have any default keyboard shortcuts, but if you enter MonoDevelop-Unity menu item and reopen Preferences window, you can add your own under “Key Bindings”. This also shows everything I just highlighted and more.

New users to Unity tend to ask about an integrated support for localization within the editor (built-in tools), currently Unity does not have this, so users ask for solutions and what’s available to get this setup. I found a free package on the asset store titled Language Manager – which is a key based system and easy to integrate multiple language support for your games and apps. Let’s take a deeper look into the package and highlight the ease of use in getting it setup:

Getting Started:

Create an AssetStore Account if you haven’t got a UDN account setup already

Download and import the asset package into a new project – Best to test it out before directly importing into your current professional project

Within your new Unity project, you will see a folder named “LanguageManager” in the project window. The folder contains the scripts and resources needed to add localisation support to your game or app, included support already for 6 different languages. We shall take a quick look at the sample scene included.

Double click the sample scene to open – click the main camera in the hierarchy window and notice the script component named: TestScript.

The script contains:

A GUI Selection Grid, allowing the user to press a GUI button to switch languages

A public string which gives the option to select the default language in the inspector

A Switch statement containing support for all 6 languages (English, Spanish, French, Italian, Chinese and Russian)

Hit play and observe the two GUI sentences at the top left of the game view are rendered in your chosen default language, the GUI buttons below allows the user to switch to a different language, clicking Russian will update the text to be displayed in Russian characters as well as for the GUI buttons. This example scene can be adapted to be used as a Language menu screen at the beginning of your game / app or in the main menu screen

It’s also worth mentioning you can get the system / OS language from an API call Application.systemLanguage – this returns the users OS default language, works on Mobile devices as well as PC, Mac and other major platforms, some are not supported so ensure to test that out. Example code for this in C# of course:

Back to the LanguageManager package,. There is a custom Window included in the Unity Window drop down menu -> Language Editor, this allows the user to create new keys and create files for different languages (I imagine as many you like). The package contains support for an initializer – LanguageManager.LoadLanguageFile(defaultLanguage); and use it by calling – LanguageManager.GetText(“string key”); That’s where you relate your key’s added in the Language Editor window, for example the string key for English language is “english”. 🙂 – with just a few lines of code you can get basic support for multiple languages within your games / apps and apply them to GUI elements in your scene/s.

Take a look at the package, it’s a free download after all, also checkout the many other packages on the Asset Store here.

Yes..the much talked about, highly requested 2D feature is finally here and available to you all for free. In preparation for the Unity 4.3 release, I developed a small 2D physics puzzle game which enabled me to get up to speed with the toolset and also use for demo / presentation purposes on my travels.

This post will go through some of the new 2D tools, workflows and shed a little light on how to use the different features available.

2D Defaults

First new feature is the 2D defaults option in the project wizard, this sets up the unity engine to use 2D for defaults on things such as the texture importer, textures will now be imported as sprites automatically instead of needing to change the texture type in the asset importer.

There are other subtle touches with using 2D defaults, such as the main camera setup as orthographic and not perspective.

A new addition to the scene window is a little toggle button which if clicked on toggles the scene between 2D and 3D, using 2D defaults means the scene view will have 2D toggled by default without needing to click the button on launch, navigating the scene in the x and y axis only. Also note, creating a new project with 2D defaults enabled doesn’t mean you’re now bound to 2D, all 3D and 2D features are still available.

In the 2D viewport in the scene view, with the move tool and the sprite selected we now have a new gizmo to play with, this makes it a lot easier to do actions such as: move, uniform / linear scaling, rotation and highlights the pivot placement. We do not need to switch between different tools, it’s all there in one place.

Box2D Physics Integration

Implemented is the Box2D physics engine, a free open source 2-dimensional physics engine and is considered a leading industry standard. With Unity 4.3 we now have a list of new 2D physics components:

3 / 4 of the colliders are self explanatory but the more interesting one to look at closer is the Polygon collider.

Add the component to your sprite asset in the same way you would add any component and you will see a green highlighted collider outline, the green lines indicate it’s a collider and it should roughly match the shape of your sprite.

If you added the Polygon Collider to an empty GameObject a Pentagon shape will be generated, If you expand the “collider info” in the component you will see the value of 5 Vertices, a Pentagon is made of 5 points therefore 5 Vertices.

To add more Vertices hold down shift + left mouse button anywhere on the green collider line and then position your Vertices, to delete Vertices use ctrl + left mouse click in the same fashion as adding them, you will see the green collider line update to red to indicate delete is available:

The Sprite Editor

There’s a new window to edit sprites in, it’s called the Sprite Editor and can be opened in two ways, Window -> Sprite editor, or click on the sprite asset in the project window, in the inspector change sprite mode to “multiple” and click the Sprite Editor button.

Note: You need to change the sprite mode to multiple to be able to slice it up in the Sprite Editor.

Let’s take a look at the Slice menu, this will give you options to slice up different elements of your sprite image automatically or manually.

A typical workflow is to slice up the image manually, you can do that by clicking and dragging on the image, you should see a blue rectangular gizmo appear with handles in the corners allowing you to resize your slice area. Having positioned and resized your slice area you can add another by following the same action, and you can add as many as you like. You will also notice a new Sprite window appear giving you extra tools to play with, you can rename the area for that sprite slice and edit the size of the rectangle by coordinates. The Trim button will tightly pack the slice rectangle based on transparency, so it will fit nicely along the edges of the sprite image.

In many cases you can probably use the automatic slicing, Unity will do the work for you and therefore save some time. Using the Automatic slicing option, the Sprite Editor will guess the boundaries of the sprite _again_ by transparency.

The Grid is another slicing option available, very useful for rectangular sprites, the Pixel Size means you can define the height and width of the tiles in pixels.

After automatic slicing you can still edit the slices manually, also use the Trim button to tighten them up.

Lot’s of other cool stuff included such as using the Animation window to easily animate sprites, using Mecanim for 2D blendtrees but I won’t cover that right now.

To finish up here’s some useful info:

Box2D Performance tips:

Try to avoid a lot of OnCollisionStay callbacks, this will be expensive.

Profiler is your friend, scroll down in the Profiler to Profile Physics2D and profile early in your development cycle.

Using the Polygon Collider can be expensive if lot’s of Vertices are needed, Polygon Collider decomposes the Sprite into lot’s of shapes which has a huge overhead.

Each shape can produce up to two contact points, having a Sprite with 50-80 shapes then it could produce double that in contacts.

Keep an eye on the amount of contacts from dynamic bodies, if they don’t collide you can have hundreds maybe thousands moving around, when they come into proximity performance starts to crumble

Circle Collider is your friend.

Consider all of the above especially when targeting low-end mobile hardware