AuthorTopic: Anyone using Unity for pixel art games?  (Read 3855 times)

Offline Cherno

  • 0010
  • *
  • Posts: 122
  • Karma: +0/-0
    • View Profile

Anyone using Unity for pixel art games?

on: May 06, 2016, 10:01:45 am
Hello,

I've been using Unity for 3D games for a few years now, but only recently have I begun dabbling in the 2D side of things. In particular, I'd like to find out to what degree Unity is capable of producing pixel art games, because the pixel-perfect...ness that is required for smooth looks is difficult to achieve.

Is there someone who has experience with achieving this? What are your tricks, if you like to share them? :)

Offline wzl

  • 0010
  • *
  • Posts: 298
  • Karma: +1/-0
    • View Profile

Re: Anyone using Unity for pixel art games?

Reply #1 on: May 06, 2016, 03:20:41 pm
I'm in no way a seasoned unity dev, i only checked it out for a brief time to see if it is viable for my requirements.
For the most part it isnt. the only way it has that's handy to me is the inspector/live value preview

In terms of pixel capabilities i wrote everything from scratch. Using VBO's to create maps, using UV offsets for animations. That works reasonably well, but defies the point of using a high level engine like unity wants to be.
Other than that i found the lack of frame capping annoying (no way to hardcap frames/physicsupdates to 60fps from what i've learned) and i didnt really found a good way to set up the viewport for decent 1x/2x etc scaling, although i'd reckon that can be worked out somehow.

Basically, you get some handy features unity has, like multiple compilation targets and the inspector, but otherwise you likely have to handcraft everything else, since unity's 2d support is really lackluster.

There is also unity2d which is in alpha right now which tries to amend some of these shortcomings but you wont be able to access it without licensing the engine.

I'd love to hear some thoughts on unity's 2d viability from seasoned unity dev's as well though

Offline Gragh

  • 0001
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile

Re: Anyone using Unity for pixel art games?

Reply #2 on: May 30, 2016, 09:13:10 pm
There are a few 3rd party tools in the unity asset store that make 2D pixel art games easier to deal with.  You pretty much can't look up pixel game dev in Unity without running into the TK2D package.   I haven't used it to its fullest yet,  but what I've experimented with so far seems to be pretty good.    There is a "pixel perfect" setting in the TK2D camera that should work unless you start messing with zoom values.  I think the sprite storage is also more efficient than Unity's built-in method.

Other than that i found the lack of frame capping annoying (no way to hardcap frames/physicsupdates to 60fps from what i've learned)

I'm not sure about physics,  but I am pretty certain you can cap the update frame rate as an application setting.

Offline kriss

  • 0010
  • *
  • Posts: 124
  • Karma: +0/-0
    • View Profile

Re: Anyone using Unity for pixel art games?

Reply #3 on: May 30, 2016, 10:12:16 pm
i'm a beginner with unity and i'm interested about info too. A friend of me told me he prefer use unity3d to make 2d platform games !
For pixel perfect, it seams the most important thing is the camera ratio

Offline Mnots

  • 0001
  • *
  • Posts: 37
  • Karma: +0/-0
    • @_Mnots
    • http://pixeljoint.com/pixels/profile.asp#iv
    • View Profile
    • Livingston Games

Re: Anyone using Unity for pixel art games?

Reply #4 on: May 31, 2016, 12:48:58 am
i'm a beginner with unity and i'm interested about info too. A friend of me told me he prefer use unity3d to make 2d platform games !

Unity2D is still handled as a 3D engine, it just locks off the z axis in camera views, but that's sort of what makes it nice at the same time. You can employ certain 3D elements to the game, such as water. Ori and the Blind Forest used Unity like that. It's a great example of what's achievable in Unity on a 2D level.

Offline Cherno

  • 0010
  • *
  • Posts: 122
  • Karma: +0/-0
    • View Profile

Re: Anyone using Unity for pixel art games?

Reply #5 on: June 02, 2016, 11:41:54 pm
If anyone is interested, I wrote a simple script that makes a GameObject always stick to whole pixels.
How to use:
1. Make the GO that contains the SpriteRenderer a child of another GameObject which has not SpriteRenderer (either could have things like Colliders and other scripts).
2. Put the PixelPerfect script onto the child GO that contains the SpriteRenderer
3. Open the script and set the pixelsPerUnit value to whatever you want (1, 16, ...) depending on your resolution. If each tile is equal to one unity unit, then you would set to 16. If each pixel is equal to one Unity unit, then set it to 1. The variable is not public so that you can change the value inside the script and each instance of the script will be affected without having to go over each instance manually.
4. The script has the attribute [ExecuteInEditMode] so you can drag aroung the parent object and see that the child object which has the SpriteRenderer and PixelPerfect script snaps to whole pixels.
5. Note that since the Start function is not called in Edit mode, is is instead called in Update, but only if the game is not running.

Code: [Select]
using UnityEngine;
using System.Collections;
using System;

[ExecuteInEditMode]
public class PixelPerfect : MonoBehaviour {

private int pixelsPerUnit = 16;
private float snapValue = 0.0625f;

// Use this for initialization
void Start () {
snapValue = 1f / pixelsPerUnit;
}

// Update is called once per frame
void Update () {
if(Application.isPlaying == false) {
snapValue = 1f / pixelsPerUnit;
}
Vector3 pos = transform.parent.position;
pos = new Vector3((float)Math.Round(pos.x / snapValue) * snapValue, (float)Math.Round(pos.y / snapValue) * snapValue, (float)Math.Round(pos.z / snapValue) * snapValue);
transform.position = pos;
}
}

Offline Zambzz

  • 0001
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile

Re: Anyone using Unity for pixel art games?

Reply #6 on: June 06, 2016, 05:04:41 pm
I thought about using unity for my games to begin with but now I've decided to move over to the Godot engine which uses GDscript which is super close to python, so gave me a way to check out python, Godot is completely free and open source and im having a blast using it.

Did take me a while to make up my mind because of the popularity of unity3d and the documentation, but godot has a dedicated 2d engine at its core (it also has 3d too)

if your up to seeing what other engines are out there, definitely check it out http://www.godotengine.org/