Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have read the whole unity manual and watched the videos on sprites but I have a question. Is there any way of creating primitive 2D shapes in unity? (I will be assigning trigger colliders to these as well). Or does one need to have a 3rd-party program even for basic primitive 2D shapes? My game really is very minimalist.

I did think about using particle system in a clever way but that won't have triggers and may not be as memory efficient for the several basic shapes that I am after.

share|improve this question

Yes, the Mesh object used for the MeshFilter and MeshRenderer can be modified to create any kind of 2D shape you like.

You'd do this by generating a 2D mesh of triangles to represent the shape you want. The bonus to using a Mesh object is that you can automatically use that as a collider too. This means that your shapes have easy interaction with operations like click detection and ray casting.

The Unity Manual partially covers how to generate these. I made a video tutorial about it (sorry it's paid). There's also a number of YouTube tutorials of varying quality.

Further, it's completely possible to create a 3D model (that's 2D) in a 3D modeling application and import it into Unity. Again, this will use the Mesh object and you can use the generated mesh as a collision mesh too.

share|improve this answer
    
Thank you for your kind reply. And what will the performance be like if I have many of these Mesh objects in the scene instead of the same number of sprites? – Tomatoes Feb 11 '15 at 21:19
    
BTW that course is on my MUST-BUY radar. It's an amazing course from what I can tell from the few preview vids. Keep up the good work, sir! – Tomatoes Feb 11 '15 at 21:21
    
Mesh objects are very common in Unity, they're used for most objects displayed in the game. I think your performance will be just fine. My course does cover object pools in the Optimization chapter, which may be useful if you have a number of these objects being loaded and unloaded. You can do a 10-day free trial of Lynda.com, my course included. Make sure you have some spare time to get the most of your 10 days :) – Byte56 Feb 11 '15 at 21:35
    
I can't thank you enough! Hopefully, my mobile game won't get bogged down by them BUT I will make sure I check out your course and optimization chapter just to be on the safe side. Amazing stuff – Tomatoes Feb 11 '15 at 21:39
2  
Just as a side note: Mesh colliders are more expensive than cube or sphere colliders, as they must be recomputed every time the mesh is moved, rotated, or scaled. – Draco18s Jan 13 at 16:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.