Search Unity

#unitytips from community all-star, Code Monkey

February 4, 2022 in Games | 5 min. read
Code Monkey Banner
Code Monkey Banner
Topics covered
Share

Is this article helpful for you?

Thank you for your feedback!

We recently invited Code Monkey for his second Dev Takeover on our @unitygames Twitter account. He came ready to answer your burning questions and shared some stellar #unitytips with the community.

If you don’t know @UnityCodeMonkey yet, you might recognize his Twitter avatar of a playful (and surprisingly tech-savvy) animated monkey. As he continues to navigate Unity, he aims to make gamedev easier with a series of best practices and speedy shortcuts. Read our latest roundup of must-try tips on topics ranging from simple Destruction and Minimaps, to the new input system and Screen Space Ambient Occlusion (SSAO).

Take on Destruction in just 90 seconds 💥

If you’re planning to use the Destroy function, look no further:

  • Grab a mesh you want to destroy, then install ProBuilder
  • Go to Edit > Preferences > ProBuilder and enable Experimental Features.
  • From there, go to Tools > ProBuilder > Experimental > Boolean Tool.
  • Duplicate Object and click ProBuilderize.
  • Create Cube and click ProBuilderize.  
  • Drag Object, position Cube, and apply Intersection to cut one piece.
  • If your object starts to disappear, click Center Pivot.
  • Move and scale Cube to cut multiple pieces.  
  • Put all the pieces into one Prefab.
  • Add a Rigidbody and MeshCollider to every piece and toggle Convex.
  • On Bullet Collision, destroy Object, then spawn Pieces Prefab.
  • Bonus: Call Rigidbody.AddExplosionForce();.

Now watch the destruction take place!

Learn the new input system in just 60 seconds 🕑

The new input system might look complex at first, so let’s break it down together:

  • First, go to Package Manager and install the system.
  • From there, create an Input Actions Asset.
  • Define Action Map and set up Type.
  • Define Binding, then listen to Input.
  • Be sure to save the asset.
  • Add a PlayerInput Component.
  • Assign the Input Actions Asset.
  • Select a method (Code Monkey recommends UnityEvents).
  • Put the target function to Action.

You can even check out the Input Debugger for more options.

Smooth things out with Lerp 👈

Snappy movement can look quite janky, but this quick tip should do the trick:

Make a Minimap in under a minute 🗺

Follow these simple steps to make a Minimap:

  • Create a second Camera.
  • Place it above, pointing down.
  • Set it as Orthographic.
  • Create a Render Texture.
  • Assign the Render Texture to Camera Output.
  • Add a Sprite to Player/Objects, pointing up.
  • Assign the Sprite to a Minimap Layer.
  • Change Camera to only render the Minimap Layer.
  • Create Raw Image on UI.
  • Assign Render Texture.

And you’re done!

Enable URP-compatible SSAO to make your game look great ✨

Did you know that the Universal Render Pipeline (URP) has Ambient Occlusion? Use this effect to add in tiny shadows:

  • Select Render Pipeline Asset.
  • Choose the Render.
  • Add Renderer Feature > Screen Space Ambient Occlusion.

Play around with the different values until you get the look you want.

More mind-blowing #unitytips 🤯

These are just some of the tips from our latest Dev Takeover with Code Monkey. If you’re looking to learn more, be sure to check out his YouTube channel – there are tons of videos to be discovered. You can also follow our Twitter for weekly #unitytips and monthly Dev Takeovers.

We can’t wait to see what you create. 🎨

February 4, 2022 in Games | 5 min. read

Is this article helpful for you?

Thank you for your feedback!

Topics covered