So, I posted that gif of the title screen on reddit the other day. A lot of good discussion going on. Something came up thanks to u/Archimagus that caused me to refactor the code that moves my camera.

Previously, it looked something like this.

if (currentDirection.x == 1){

if (transform.position.x < targetPositions[x].x){

Move camera code



This went on for direction being -1, and for y and z as well. All in all, to move the camera was 122 lines of code.

After Archimagus reminded me of some basic functionality, it’s now looks more like this:

if (Vector3.Distance(transform.position, targetPositions[x]) > threshold){

Move camera code


And that’s it.

18 lines.

104 lines of garbage code eradicated. Felt pretty good. I also use Mathf.SmoothDamp now for determining the movement, and it makes it a lot smoother.

Needless to say it makes it obvious both how new to Unity I am, and how rusty I am at programming that I forgot about calculating the distance between two Vector3’s.

Note on Graphical Assets

I just wanted to make a note that the graphical assets of Dungeon Diver while it’s in development are not indicative of the final graphics or style we may be going with. Right now we’re mostly using free assets off of the Unity Asset Store just so that we can more easily visualize what we’re doing, as neither of us are artists to any decent degree.

Some assets (such as the menu stuff that I haven’t showed off yet) are more likely to be final however.

Just something to keep in mind as more things get shown off! 😀