Forum begins after the advertisement:

[General] Creating Thunder Loop (Lightning Ring Evolution)

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [General] Creating Thunder Loop (Lightning Ring Evolution)

Viewing 1 post (of 1 total)
  • Author
  • #15043
    Joseph Tang

    This is a post to provide detail on how to create the Thunder Loop Weapon Evolution for our Rogue-like Shoot-em Up series.
    To do this we’ll be going through 3 things:

    1. Setting up a Thunder Loop VFX.
    2. Writing the Thunder Loop Projectile Script.
    3. Creating the Weapon Data and Evolution Data.

    For convenience, below are the links to the article and the video that our code & scriptable objects will be based off:

    The Thunder Loop is the evolved form of the Lightning Ring. It performs the same function as the Lightning Ring, but after the first strike of lightning, another strike will follow shortly after on the same spot. To create this weapon, we will need to give it: a new Thunder Loop VFX, a new behavior script to change it’s function from the Lightning Ring, and setting up it’s Weapon Data.

    1. Setting up a Thunder Loop VFX

    [This will be the bulk of what makes the Thunder Loop as the visuals will be more elaborate than the code (Which will only handle the damage)]

    • Duplicate the basic “Lightning Ring VFX” Prefab and name it “Thunder Loop VFX”. Rename both the “Shockwave” and “Smoke” to “First Shockwave” and “First Smoke”.
    • Create a new gameObject in the Prefab, name it “First Lightning”, and give it the same Particle System as the parent object before disabling every part of the Particle System except for the “Texture Sheet Animation” on the parent object.
    • Duplicate the “First” “Shockwave”, “Smoke”, “Lightning”, and rename the new duplicates as “Second”. For each of the “Second” Particle System’s, Change the “Start Delay” from [0] to [1]. This makes sure that a second lightning will always hit a second after the first.
    • Copy and Paste the Particle System of the “Soul Eater Aura”‘s “Smaller Aura”. We’ll apply this Particle System onto 2 new Game Objects, “Smaller Aura” and “Bigger Aura”.

    Both “Smaller” & “Bigger” Aura:

    1. Set “Duration” and “Start Lifetime” to [1].
    2. Change the “Start Color” to Yellow/Orange.
    3. In Emission: set “Rate Over Time” to [0]. Add a “Burst” of: Time: [0], Count: [1], Cycles: [1], Interval: [1]. Probability: [1].
    4. Deactivate “Color Over Lifetime”.
    5. “Bigger Aura”:

    6. Deactivate “Size Over Lifetime”. This will ensure the “Bigger Aura” remains the same size, while the “Smaller Aura” closes in.

    • Finally, we’ll create a final Particle System on a new GameObject, “Electric Field”. This will act as a particle spawner within the Aura.

    “Electric Field:”

    1. Set “Duration” and “Start Lifetime” to [0.5]. This will make sure that the Particles will disappear until
    2. Change “Start Color” to “Random Between Two Colors”, then set the colors to Red & Yellow.
    3. Set “Max Particles” to [100].
    4. In Emission: Set “Rate Over Time” to [100].
    5. In Shape: Change “Shape” to “Sphere”, “Radius” to [4].
    6. In Renderer: Set the “Material” to “Additive-Particle”, or “Default-Particle” [Part of Unity’s Resources]. (You can choose any fitting particle for this effect)

    Final Changes for Everything:

    1. Ensure all Particle System’s “Sorting Layer ID” is set to “Foreground”.
    2. Change the Transform Scale to [2] for “Bigger” & “Smaller” “Aura”.
    3. Change the Transform Scale to [0.5] for “First” & “Second” “Lightning” & “Smoke”.
    4. Change the Transform Scale to [0.2] for “First” & “Second” “Shockwave”, and “Electric Field”..

    View post on

    A look at the Thunder Loop VFX and it’s Particle System values.

    2. Writing the Thunder Loop Weapon Script

    • Create a new subclass script called “ThunderLoopWeapon”, inheriting from Projectile.cs. This script will be an exact copy of the LightningRingWeapon.cs.
    • Create a new Coroutine, IEnumerator Strike().
    • In Attack(), we’ll delete the code within the if statement finding target, using PickEnemy(), that calls the DamageArea() and Instantiate()‘s the Lightning VFX. We’ll replace the code to call Strike().
    • In Strike(), find the target enemy with EnemyStats target = PickEnemy() to find the position of the enemy and set it as a Vector2 strikePosition for our Thunder Loop attack.
    • We’ll then call DamageArea() to deal damage to the enemies at strikePosition.
    • For the VFX, we’ll set the Instantiated VFX as a ParticleSystem thunderLoopVFX. This will allow us to change the angle of the VFX to manipulate the first “Lightning” to strike diagonally.
    • Instantiate the VFX at the strikePosition and at a Quaternion.Euler() random value angle Z of either [45] or [-45].
    • Next we’ll set the transform.localScale of thunderLoopVFX to GetArea(). This will scale up the Instantiated VFX by the area of the attack for accurate representation of the damage range.
    • We’ll then call WaitForSeconds() before resetting the thunderLoopVFX‘s Quaternion.Euler() to [0,0,0]. This will reset the final lightning to strike straight.
    • After calling WaitForSeconds() for a total of 1 second, we’ll call DamageArea() again at strikePosition.

    [Reminder: This code is a duplicate of the LightningRingWeapon.cs code]

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class ThunderLoopWeapon : ProjectileWeapon
        List allSelectedEnemies = new List();
        protected override bool Attack(int attackCount = 1)
            // Find an enemy in the map to strike with lightning.
            EnemyStats target = PickEnemy();
            if (target)
                DamageArea(target.transform.position, GetArea(), GetDamage());
                Instantiate(currentStats.hitEffect, target.transform.position, Quaternion.identity);
        IEnumerator Strike()
            // Find an enemy in the map to strike with lightning.
            EnemyStats target = PickEnemy();
            Vector2 strikePosition = target.transform.position;
            DamageArea(strikePosition, GetArea(), GetDamage()); 
            float randomAngle = Random.value < 0.5f ? 45f : -45f;
            ParticleSystem thunderLoopVFX = Instantiate(currentStats.hitEffect, strikePosition, Quaternion.Euler(0,0, randomAngle));
            thunderLoopVFX.transform.localScale = new Vector3(GetArea(), GetArea(), GetArea());
            yield return new WaitForSeconds(0.9f);
            thunderLoopVFX.transform.rotation = Quaternion.Euler(0, 0, 0);
            yield return new WaitForSeconds(0.1f);
            DamageArea(strikePosition, GetArea(), GetDamage());

    3. Creating the Weapon Data and Evolution Data

    Thunder Loop Weapon Data

    Set the values to the following image for the Thunder Loop.

    Lightning Ring/Duplicator Evolution Data

    • Select the Lightning Ring & Duplicator Scriptable Object & add a new “Evolution Data” to it.
    • Set the “Condition” to “Treasure Chest” & the “Consumes” to “Weapons”, ensuring the weapon only evolves when picking up a chest and will only remove the weapon involved with the evolution.
    • Set the “Evolution Level” to [8] for the Lightning Ring and [2] for the Duplicator, before adding the “Catalyst” which selects the other weapon/passive item for the corresponding level of [8] & [2].
    • Select the Thunder Loop Scriptable Object as the outcome and set it at level [1]

    Set the Evolution Data to the following image for the Lightning Ring. [Copy the setup for the Duplicator]

    That concludes how to create the Thunder Loop Weapon.
    [Note: I am aware that the “Lightning” Particle effects are sometimes invisible as they spawn in outside of the camera’s range. I will update this post when we are able to fix it.]

    If you encounter any issues in creating the Thunder Loop, you can submit a forum post to go into detail on your problem for further assistance.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Go to Login Page →

Advertisement below: