Helpful tips in creating functunalities

Here are some tips in how to create a new functionality, according to me: If you have something that is not so simple, write pseudocode...

Monday, January 28, 2019

How I've fixed the "Jiggly" effect of my Unity 2D game

So, first of all, I had a real tile problem. See the "gaps" of the tiles kept on changing size (decreasing and increasing) as my camera moved. You can see it in this video here: https://www.youtube.com/watch?v=BtkgLe50iY0 (see the gaps of my tiles while my character moves). I have fixed it from using the code from here: https://forum.unity.com/threads/setting-up-unity-for-pixel-perfect-2d-project.268807/ . You can also see/read this article about the same thing here: https://hackernoon.com/making-your-pixel-art-game-look-pixel-perfect-in-unity3d-3534963cad1d
Now this has caused my character to have the Jiggly effect described here: https://stackoverflow.com/questions/35785291/getting-giggly-effect-when-slowly-moving-a-sprite . I still couldn't figure out how to fix it until someone has given me an idea. I have used a Tilemap feature to place the tiles. The tiles have a 32 PPU (Pixels Per Unit). I have set my character from 100 PPU to 32 PPU (just like the tile PPU) and it seems it has worked. My character no longer looks weird when walking. I can just resize the tiles and my character using the regular Transform Scale.
I hope this helped anyone in need of help here.

Edit: I have so far had a problem with my character having the Giggly effect again. What I've changed is add my Pixel Perfect Camera code to my character instead of my Camera (because the camera is my child object of the character and you can't use the local position like this) and I have made my camera's local positions 0.1, 0.1, 0 instead of 0, 0, 0.

Saturday, January 26, 2019

Pixel Perfect Movement for your 2D game's tile problem

I have had a problem where my 2D game's tile "gaps" kept on increasing and decreasing in size. Here it is in the video:

Here is the article that has solved the problem: Setting up Unity for pixel-perfect 2d project .

Here is the code that I've attached to my character (the camera is a child GO of it):

void Update()
    {
        Vector3 roundPos = new Vector3(RoundToNearestPixel(transform.position.x, Camera.main), RoundToNearestPixel(transform.position.y, Camera.main), transform.position.z);
        transform.position = roundPos;
    }
    public static float RoundToNearestPixel(float unityUnits, Camera viewingCamera)
    {
        float valueInPixels = (Screen.height / (viewingCamera.orthographicSize * 2)) * unityUnits;
        valueInPixels = Mathf.Round(valueInPixels);
        float adjustedUnityUnits = valueInPixels / (Screen.height / (viewingCamera.orthographicSize * 2));
        return adjustedUnityUnits;
    }

Tuesday, January 22, 2019

Entertainment Software Rating Board (ESRB) Video Game Age Requirement Guide

Here it is: https://www.esrb.org/ratings/ratings_guide.aspx

Unity: Why you have serious problems with your connected controller

So I had a serious problem with using my connected-to-computer joystick to use in my Unity game. What happened was that when I have added movement to my in-game character, he would constantly move somewhere, as if a pad/stick was being moved. I couldn't solved it for a while until I have changed the "Axis". I have changed from X-Axis and Y-Axis to 5th Axis and 6th Axis. Now the problem is solved.

The Art of Game Development

The Art of Game Development
A Guide for Beginners (eBook)