Visual Ideas & Tests (Week 3)


Visual Ideas & Tests (Week 3)

I have adjusted the city model so it scales nicer from its pivot point, I fixed some bugs, and I made a sun shader, as well as a few other things.

Published on December 02, 2019 by Amy Elliott

C# Programming Unity 3D Art Shaders & Technical Art Dev Blog College

9 min READ


Please note: The code and content within this blog post is not representative of my current skills.


Week Number & Date: Week 3 - 02/12/19

List of Tasks planned for this week:

Tasks

This week I had completed everything on my Week 3 checklist in my previous list, so I decided to set myself some tasks at the beginning of the 3rd week, relating to making the game comfortable to play for the player.

Current Position -

What did I do this week?(Screenshots/Videos/Photos & annotations)

Maya - Change pivot point

Task

Issue

I decided to start with this one since it’s been bugging me for a while and I want to fix it, the city buildings scale from the pivot in the middle of the object which is what I don’t want them to do, so I’m going to change that so they scale from the bottom of the object instead.
I didn’t know how to do this at first so I used a Maya documentation blog to help me out on doing this.
I changed the pivot point by selecting all of my buildings and pressing D I then moved the point down using the move tool.

Example

This now means that the objects scale from the bottom of the buildings, but not all of then were aligned to the middle of the buildings, so I began aligning them to where they needed to be.

Alignment

This is the result:

via GIPHY

I then added this into Unity.

Task

Unity - Fix Bouncing Bug

Bug Ticket

This bug wasn’t really a bug, it’s just where the buildings moved too fast and the player with a mass of 10 was trying to land on them to bounce themselves up, that wasn’t working, but it was an easy fix, all I had to do was lower the mass to 1 and then go into the project settings in Physics and change the gravity, this isn’t related to the bug but it makes the game play smoother and the character jump quicker.

Settings

Task

Unity - Camera Adjustment 

Task

Inspector

This was first basically going to work so the player moved forward in whatever direction the camera is in, the camera is confusing since it moves really fast whenever the player moves and it makes controlling the character a lot harder.

I originally started this by re-writing my character controller script so the player moves in whatever direction the camera is pointing in, but then I realized it would be much better if I just worked on the camera, so I kept the character controller script as it is,
I instead just stuck with adjusting the camera to work how I want it to and make it fun to control the player character, these are the settings on my Cinemachine Camera component to do what I need it to do.

Result:

via GIPHY

Task

Unity - Colour Pallet

Task

I done this by going pallet by pallet and then setting them all down and picking which one I like the best, this colour pallet will effect the grid colour, bloom colour, directional light colour and the fog colour.

Grid 1 - 

Grid1

Grid 2 - 

Grid2

Grid 3 - 

Grid 3

Grid 4 - 

Grid 4

Grid 5 - 

Grid 5

Grid 6 - 

Grid 6

Once I was done with making all of these, I made a google form which I asked different people to fill out.

Form

This is good because I don’t just want to pick my own favorite colours, but I want to get a general idea of what everyone likes as an average, so I can pick that one that more of the general audience likes.
I waited for the responses to come through.

The next morning I checked the responses for the colour scheme, and a lot of people like the 3rd colour scheme since the majority of them picked them with that colour scheme in.

Results

Results

This is the final colour scheme:

Final Colour

Chosen colour

Task

Unity - Sun

Sun Task

Right now I’m planning as I go along, and I have no idea how I’m going to make this sun work, I think the best way is to use a shader graph in unity and apply it as a material to a sphere 3d object but make the sun stay in one place.
This is the result of the shader graph I used.

Nodes

To make the sun show, I needed to get rid of the fog I had.

Fog

Task

Unity - Collision Deletion

Task

I wanted to add some basic game play into this and I decided that it would be fun if I make it so the buildings disappear once you step on it, the script below is what I made to make this work, with changing the colour of the material, I had to use _BaseColour instead of .material.color = Color.red since I was working in LWRP (Light Weight Render Pipeline)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CollisionDelete : MonoBehaviour
{
    // This is the health of the buildings, so how many times the player can bounce on the building before it gets destroyed.
    private int buildingHealth = 3;

    void OnCollisionEnter(Collision collision)
    {
        // This detects if the collision of the game object is colliding with the Character's collider.
        if (collision.gameObject.name == "Character")
        {
            // This takes away 1 from the building's health each time it gets collided with.
            buildingHealth--;

            if (buildingHealth == 0)
            {
                // If the health of the building is equal to 0, the building is deactivated,
                // NOT destroyed; otherwise, the game would break.
                gameObject.SetActive(false);
            }
            else if (buildingHealth == 1)
            {
                // Else, if the game object's health is equal to 1, it gets the material
                // and changes its color to red.
                gameObject.GetComponent<Renderer>().material.SetColor("_BaseColor", Color.red);
            }
            else if (buildingHealth == 2)
            {
                // Else, if the game object's health is equal to 2, it gets the material
                // and changes its color to yellow.
                gameObject.GetComponent<Renderer>().material.SetColor("_BaseColor", Color.yellow);
            }
        }
    }
}

Result:

via GIPHY

I didn’t really like how these colours looked, I wanted to use colours on my colour pallet, or at least something close to that.
At first I was struggling with getting it working since I was using Color instead of Color32 for my RGB values.

Code

This wouldn’t work since color is only between values 0 and 1, whereas if I wanted values between 0-255 I would need to use Color32, I would use Color if I really wanted to, but I would have to divide my values by 100. This is the result:

via GIPHY

Task

Unity - Mountains**

Task

I didn’t want to make anything too detailed in my background, so I wanted to go with a simple 2D quad rotated to look like a mountain in the background, this was easy, I made a quad and I applied a new material to it which is derived from the grid shader graph, editing this materials properties so it’s just an outline around the quad, I then put the quad in the scene and rotated it to look like a mountain, putting it in front of the sun, I then made this quad a prefab and duplicated it, moving it all around, this is the result:

Mountains

Task

A quick change I made was adding this into my script so that the minimum size the buildings could be wasn’t below the ground, so I can actually see all the buildings when I begin playing.

void Update()
{
    float[] spectrum = new float[2048];
    SRC.GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris);

    for (int i = 0; i < buildings.Length; i++)
    {
        var targetScale = spectrum[i] * musicMultiplier;

        var scale = Mathf.Lerp(buildings[i].localScale.y, targetScale, lerpSpeed);
        buildings[i].localScale = new Vector3(1, scale + 0.05f, 1); // Here at 0.05f
    }
}

Planning for next week -

  • How do I plan to catch up? 

There isn’t anything I feel like I need to catch up on, this is because I’ve done more work then I initially had planned on my trello board, so I’m going to start my Task 5 Planning, production and practical skills for next week.

  • Do I need to change anything about my work or planning?

I’ll need to change my Trello board and plan ahead, making plans for my planning and production for Task 5.