Skill Tree Activated

The quest to become an indie game developer

#100DaysOfCode#100DaysOfGameDevC#Illogical BaconPanic RoomScript-writingUnityVisual Studio

Pivot!

#PanicRoom Day 077

#100DaysOfGameDev R2D42
#100DaysOfCode R2D42

I have been struggling to wrap my head around why my floor tiles appear perfectly on my grid overlays, but my wall tiles are always off. I have analyzed the code exhaustively been have been unable to find any issue whatsoever that would lead to this kind of behavior. I even did extensive debugging against my code to verify everything is being produced properly, and all my testing says it is. So where is this shift in my placed tiles coming from?

changed floor tile pivot

That’s when it hit me: could it be my sprite pivot points? Sure enough, with a little playing around, I was able to shift my wall tiles around a little just by changing the pivot points of the sprites that make them. It is good that I finally discovered this as I can now do something about it to bring everything back in line, but it is also not so good because now it has led me to things that I must address and deal with.

changed wall pivot

This first problem with changing my pivot points from center to bottom left is my floor tiles now flip differently. I had originally used center pivot because I could flip a tile either vertically or horizontally and it would remain in the same spot. This is not the case with bottom left pivot. Now if I randomly flip a cracked tile, as my floor-building code used to do, it can appear a full tile away depending on how it’s manipulated. For now I have just shut that system off and my house only generated static blank tiles. I will deal with that another day when it’s a little more necessary, right now it isn’t.

wall and floor tiles lining up

The other glaring problem I picked up on is when I invoke my grid overlays there is now a significant shift in where the grids start and where my house actually is now. I hope this is an easy fix in code and I can just alter an algorithm or two and have it back on track. The good news is my floor tiles (and basically my house) now start on 0,0 origin and build out to the right and up, which is exactly what I intended. I never noticed before that the center pivot was starting them a grid back and a grid down.

Just another case of one step forward, two steps back. This is development, I suppose. As usual, at least I’m learning.

grid overlay not lining up with fixed floors and walls

Leave a Reply

Your email address will not be published. Required fields are marked *