Laser Defender Early Previews - Cancelled

Update 20181018

Refactored code to remove all FindObjectOfType calls. Replaced by utilising a singleton instance pattern (Thank you Liz_The_Wiz for help) for GameSession and serialized fields for the rest.

Modified the UpdateWeaponConfig method to get projectileSpeed and projectileFiringPeriod from script attached to weapon prefab. It might not be noticeable as i haven’t improved the prefabs themselves yet but below is a video demoing.

Next will be either adding some sound effects, more prefabbed weapons and enemies or researching how to create multi directional bullet streams.

1 Like

Refactored code to remove all FindObjectOfType calls.

:+1:

Enjoying seeing your progress on your game Jeff, and have considered chiming in before, but didn’t want to spoil the flow of your updates - happy to remove this post if you don’t want it in the timeline. One thing I was going to suggest was the fade duration for the collected power-ups. In a couple of your videos it lives on after collected, not for long, but I found myself watching the power-up instead of watching the enemies flying in from the top - it could become a distraction for your players. Just a thought. Again, great work and really enjoying seeing your updates.

1 Like

Hi Rob.

Input like that is really valuable as it’s something I never would have considered. Any and all feedback is appreciated :slight_smile:

You have me thinking whether to freeze the objects fall and perform the animation on the spot, move the animation to the players transform.position and match movement or scrap the animation all together. I’ve set a task to rig up a demo of each for review in the near future.

Thanks again :slight_smile:

Update 20181019

Nothing visual to show for tonight’s work. Recorded some silly sound effects but haven’t added yet as realised they’ll come in later when I have a settings menu with an option to switch between normal and silly sound effects. More prefabbed weapons will come when I find how to set up more diverse weapons so can shoot in multiple directions.

What I did get done was;

  • Removed overlooked FindObjectOfType calls,
  • Fixed broken singleton implementation (thanks again Liz/Sponge Borg)
  • Set GameSession, MusicPlayer, SoundManager and SceneLoader all as singleton instances.
  • Set clamps on values for health and shieldHealth

That’s all for tonight folks.

1 Like

Hi Jeff,

You have me thinking whether to freeze the objects fall and perform the animation on the spot, move the animation to the players transform.position and match movement or scrap the animation all together. I’ve set a task to rig up a demo of each for review in the near future.

If it were me, I’d probably start super-simple and just make the fade after it’s been collected a little quicker. That way it will naturally disappear very soon after collection.

On a related note, you often see power-ups in games like this that radiate/pulse when they are available, you could then increase the speed of that pulse as it gets closer to expiring. I think at the moment you have it setup where by the power-up is always available until it goes off the screen - it’s just an alternative approach, but potentially you could use the same code for then altering the fade/pulse at the point of collision.

Thanks again

You’re very welcome, as I say I did hesitate a little as I didn’t want to interrupt your blog style development log and clutter it with my ramblings :slight_smile:

1 Like

Update 20181020

After much thought, errors and troubleshooting with assistance from people in the #Unity Discord channel, I was able to get add projectile directions to the weapons system. Here it is in action.

2 Likes

Update 20181021

Today has been mostly housekeeping.

  • Added a function to destroy parent GameObjects of weapon prefabs when no child projectiles exist.
public void DestroyWhenProjectilesExpended()
    {
        if (transform.childCount == 0)
        {
            Destroy(gameObject);
        }
    }

    private void Update()
    {
        timePassed += Time.deltaTime;
        if(timePassed >= checkForChildrenPeriod)
        {
            DestroyWhenProjectilesExpended();
        }
    }
  • Added side shredders to destroy bullets sent on angle that were not being captured by top and bottom shredders

  • Swapped out old firing system for enemies for the one created for player allowing more flexible weapon configs
  • Modified enemy shooting conditions to only shoot if on screen using OnBecameVisible and OnBecameInvisible to set bool used in fire method
private void CountDownAndShoot()
    {
        shotCounter -= Time.deltaTime;
        if(shotCounter <= 0f && onScreen) // <----
        {
            Fire();
            shotCounter = UnityEngine.Random.Range(minTimeBetweenShots, maxTimeBetweenShots);
        }
    }

private void OnBecameVisible()
    {
        onScreen = true;
    }

    private void OnBecameInvisible()
    {
        onScreen = false;
    }
  • Fixed minor bug in set enemy to spawn collectible method
  • Fixed minor bug in enemy weapon prefabs

I also tweaked the waves for my dev level to test how these changes affect game play. Here’s what it currently looks like.

Addendum

  • Fixed bug where player colliding with enemies wasn’t triggering the enemy deathFX by adding check if collided object had “Projectile tag”
public void Hit()
    {
        if(gameObject.tag == "Projectile") <-- Here
        Destroy(gameObject);
    }

And added a health boost.

1 Like

Update 20181023

  • Added player movement speed management methods to GameSession
  • Added method on Player to read speed from GameSession
  • Used weapon boost sprite (bolt) as speed collectible sprite
  • Created laser burst sprite for weapon boost collectible sprite
  • Removed power up levels to have just one power up for each attribute
    • Weapon
    • Health
    • Speed
    • Shield
  • Each power up has distinctly different colours to help differentiate
    • Weapon - white laser burst on green
    • Health - red cross on white
    • Speed - yellow bolt
    • Shield - silver shield

image
These graphics should probably still be swapped out later but for now they’ll do.

Finally here’s a video demoing the changes.

3 Likes

Looking really good Jeff, well done :slight_smile:

1 Like

thats looking really slick :slight_smile:

Well done and a thank you for sharing your progress thoughout, been a good ready to follow progress.

love the big boss, and the multi bullet weapons :wink:

2 Likes

Update 20181027

I’ve been working on a volume controller and options menu to interface with it. I finally worked out the issue with my SFX volume control was we were using the static AudioSource.PlayClipAtPoint method which seemed to ignore any input I gave on the volume parameter.

There are several posts online and some here on the GameDev.TV forum where it appears to work for some but I wasn’t haven’t luck. Rather than persist with banging my head against the wall I decided to replace the AudioSource.PlayClipAtPoint calls with audioSource.PlayOneShot(AudioClip myClip) calls. Now appears to be working and I can always revert down the track.

Here’s what the start and options menus are now looking like.

The Silly SFX option is a toggle/checkbox. I’m toying with the idea of replacing existing sound effects with voice recording of bang or pew. Here are some samples for those bored enough to be interested.

I’m using Panels on start menu canvas to display the start and options menus. When selecting Options, the start menu gets disabled and options enabled. Reverse when selecting main menu. I haven’t done anything for help section at this stage. Thinking of launching web browser / new tab to a web page with a game guide as seems more practical than creating a help scene in Unity.

Here’s the current state of my SoundManager script that sets the SFX to play.

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

public class SoundManager : MonoBehaviour {

    public static SoundManager Instance { get; private set; }

    [SerializeField] AudioClip playerShotSFX, playerDeadSFX, enemyDeadSFX, enemyShotSFX, buttonClickSFX;

    [SerializeField] AudioSource audioSource;

    [SerializeField] [Range(0, 1)] float sFXVolume = 0.5f;
    [SerializeField] [Range(0, 1)] float playerShotVolume = 1f;
    [SerializeField] [Range(0, 1)] float playerDeadVolume =  1f;
    [SerializeField] [Range(0, 1)] float enemyShotVolume = 1f;
    [SerializeField] [Range(0, 1)] float enemyDeadVolume = 1f;
    [SerializeField] [Range(0, 1)] float buttonClickVolume = 1f;

    private void Awake()
    {
        SetUpSingleton();
        SetSFXVolume(sFXVolume);
    }

    private void SetUpSingleton()
    {
        // First we check if there are any other instances conflicting
        if (Instance != null)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
        }
        else
        {
            // Here we save our singleton instance
            Instance = this;

            // Furthermore we make sure that we don't destroy between scenes (this is optional)
            DontDestroyOnLoad(gameObject);
        }
    }


    public void TriggerPlayerShotSFX()
    {
        audioSource.PlayOneShot(playerShotSFX, (sFXVolume * playerShotVolume));
    }

    public void TriggerPlayerDeadSFX()
    {
        audioSource.PlayOneShot(playerDeadSFX, (sFXVolume * playerDeadVolume));
    }

    public void TriggerEnemyShotSFX()
    {
        audioSource.PlayOneShot(enemyShotSFX, (sFXVolume * enemyShotVolume));
    }

    public void TriggerEnemyDeadSFX()
    {
        audioSource.PlayOneShot(enemyDeadSFX, (sFXVolume * enemyShotVolume));
    }

    public void TriggerButtonClickSFX()
    {
        audioSource.PlayOneShot(enemyDeadSFX, (sFXVolume * enemyShotVolume));
    }

    public float GetSFXVolume()
    {
        return sFXVolume;
    }

    public void SetSFXVolume(float newVolume)
    {
        sFXVolume = newVolume;
        audioSource.volume = sFXVolume;
    }
}

And here’s the volume controller which is attached to my volume sliders in the options menu.

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

public class VolumeController : MonoBehaviour {

    [SerializeField] Slider sFXVolumeSlider;
    [SerializeField] Slider musicVolumeSlider;

    public void SetSFXVolume()
    {
        SoundManager.Instance.SetSFXVolume(sFXVolumeSlider.value);
    }

    public void GetSFXVolume()
    {
        sFXVolumeSlider.value = SoundManager.Instance.GetSFXVolume();
    }

    public void SetMusicVolume()
    {
        MusicPlayer.Instance.SetMusicVolume(musicVolumeSlider.value);
    }

    public void GetMusicVolume()
    {
        musicVolumeSlider.value = MusicPlayer.Instance.GetMusicVolume();
    }
}

I’m next wanting to tackle the problem of game states. I’m picturing 4 potential states.

  • InMenu - Indicating player is in start menu, between levels or game over menu.
  • InEvent - Indicating player is in a scripted event/animation/cut scene. Something I hope to implement. Not a big moving event. More just a game like scene with scripted player/enemy movement and dialogue windows appearing to deliver story. Not sure how but we’ll get there… Eventually.
  • InGame - Indicating player is in an active level and playing, e.g. can shoot, move, etc.
  • IsPaused - Indicating game is paused. May cross over with InMenu.

More than likely need to break this problem into smaller bits to implement. See how I go.

If you have any advice or feedback, feel free to post here in the thread.

Take care,

HorusOfOz :wink:

2 Likes

I love the background.

The Parallax effect is also really good.

2 Likes

All credit to @Rick_Davidson for the scrolling background. I’m hoping to change the image with the help of someone much more talented than I art wise, but Rick provided the code/logic and the art in place at the time of writing (See initial post for example).

3 Likes

Update 20181030

Unfortunately, not much progress. I tried removing the requirement for destroying GameSession so that I could add a game state controller to it but kept breaking my game. After a few days of this I’ve tried to revert everything.

I’m going to take some time to do some fun stuff like making a couple new enemies, paths and levels. Also want import the great booster art provided @Kevin_teeDee :slight_smile:

medic_booster speed_boost guns_boost shield_boost

medic_booster2 speed_boost_2 guns_boost_2 shield_boost_2

Till next time :wave:

4 Likes

These sprites look great, well done @Kevin_teeDee, can wait to see these in your next game video @Horusofoz :slight_smile:

2 Likes

Update 20181101

Changes

  • Added the awesome boost sprites provided by @Kevin_teeDee. They’re double scale ATM but think I’ll take it down to 1.5.
  • Changed the power up collected animations

Bugs Fixed

  • Player projectiles continuing on after hitting enemies. I’d like this to be for later weapons only. Will have to look how to enable for the later weapons.
  • The star fields particle systems we’re emitting over the top of the player. Now behind on Z index

Bugs Found

  • WaveConfig OnEnable function to set a random boost is triggering before the singleton GameSession has made the list of boosts available.

Still a lot more to do and fix but that’s all for now folks :wink:

3 Likes

haha this is cool! Very excited to see it :slight_smile: One note about scaling, it might be different with unity, but pixel art doesn’t scale that great, so if possible try to scale it by factor of 2 (64x64->128x128->256x256 etc)

can’t wait to see more

3 Likes

Update 20181103

Changes

  • Added 3 background materials based on sprites provided by Ken (thanks again). There’s an issue with the scrolling
  • Replaced boost sprites with scaled versions
  • Updated animation for new scaled boosts
  • Removed RandomSpawnFactor from WaveConfig as don’t think I use it in the game and can’t recall where did in base game

Bugs Fixed

  • NA

Known Bugs

  • WaveConfig OnEnable function to set a random boost is triggering before the singleton GameSession has made the list of boosts available.
  • Background scrolling not working correctly when replacing texture/material

Other
Trying to develop an effective method for designing levels. Here’s what I’ve come up with so far.

First, creating images showing each of my existing paths such as;

examplePath01 examplePath02 examplePath03

Next, figuring out a method for visually planning a level while documenting details. After a bit of trial and error I’m currently using Google Slides. Not sure how scalable it’ll prove to be but here is link to what Level01 looks like at the time of writing.

I’ve just made the one level at this stage as it proved to be a lot more time consuming than I thought plus I kept uncovering things I wanted to change/add but had to be put aside to complete the level.

I’ve messed up the UI scaling terribly as this is what my menu is looking like :frowning:

Should be like this;

Anyway here’s just the level for those willing to play test such an early alpha, Enjoy :slight_smile:

Scratch that. It gets worse :frowning:

Guess I should have been building and testing a lot earlier. I’ll start trying to pick it a part and work out what the scaling issues are in the coming days.

Take care :wave:

EDIT:
Here’s a quick video showing what the game should look like. The level shown is meant to serve as a tutorial of sorts, introducing how enemies move, boosts and bosses.

3 Likes

Update 20181205 - End of the line

I’ve come to the decision to put a pin in this project. I’ve learned a lot and shared those lessons here in the updates.

The big take away is test early, often and on all the aspect ratios/platforms you intend to support.

Most of the assets are freely available via Kenney Assets. Boost sprites were kindly provided by @Kevin_teeDee.

The code is freely available on GitHub for the interested. Unfortunately I have not been able to resolve the scaling bug. However I’m leaving the project and thread up in case anyone wants to make use of some of the systems I was able to add such as;

  • Shields
  • Health/shield bars
  • Boost system
  • Multiple directional weapons
  • Volume sliders
  • Animations

Thank you @Rick_Davidson for the learning experience and to everyone who helped along the way :slight_smile:

5 Likes

Well done for putting so much extra love into the project!

3 Likes

Privacy & Terms