Dev Log #4

This week I started working on the actual levels and details on my assignment. My plan is to create 3 levels. The first will be a green mountain level, the second a cave level and the third will be in the desert.

The image above is of the first level, mountains. One thing that I discovered that you can see in the image are the lamp posts. They are just a sphere on top of a cylinder with a light, yet the sphere is different. It has a material which emits light, independent of it's surroundings. This is why it actually looks like the lamp is emitting light.

I also worked more on the enemies. First, they only follow the player around if they can see them. This is done by shooting a raycast towards the player and if it doesn't intercept a wall, then the enemy can see them. This is so that enemies don't try to walk through walls and only engage with the player if they can see them.

I also implemented more "game feel" to provide the player with more visual feedback. The first thing was damage flashing. When the enemy or player gets damaged, their material flashed red for a few frames to show that they have been damaged.

    public MeshRenderer rend;   

    //Called when damaged. Flashes enemy red quickly.
    IEnumerator DamageFlash ()
        rend.material.color =;
        yield return new WaitForSeconds(0.03f);
        rend.material.color = Color.white;

As you can see, it's a very basic block of code. It's simple but works effectively. 

Another thing I implemented was camera shake. When the player get's hit, kills an enemy or uses their jetpack the screen will shake to show that it is indeed happening.

//Shakes the camera for a duration by an amount and intensity.
    IEnumerator ShakeCam (float duration, float amount, float intensity)
        Vector3 targetPos = Random.onUnitSphere * amount;

        while(duration >= 0.0f)
            if(Vector3.Distance(cam.transform.localPosition, targetPos) < 0.05f){
                targetPos = Random.onUnitSphere * amount;

            cam.transform.localPosition = Vector3.Lerp(cam.transform.localPosition, targetPos, intensity * Time.deltaTime);

            duration -= Time.deltaTime;
            yield return null;

        cam.transform.localPosition =;

The camera shake code takes in 3 variables. A duration, amount and intensity. The way it works, is that it first finds a target position. This is done by using Random.onUnitSphere multiplied by the amount. It will find a random unit in a spherical area. Then, it moves the camera to that position at the speed of the intensity and when it arrives at that position, a new target pos is found. 

The image above shows the poison gas, which damages the player if they're inside it. The script emits the particles for a certain amount of time in certain intervals to give the player enough time to cross. In this case, the gas emits for 3 seconds with 2 second intervals. If the player is inside the trigger of the gas while it's emitting, they will be damaged 5 hp every half a second.