Can you outsmart and outmaneuver a bunch of triangles that want you to explode? TriGrid is an action puzzle game where you guide a white arrow through a maze to pierce colored triangles from behind to make them explode. There is an endless Evolution mode with a layout that changes randomly, a Survival mode where you ward off waves of enemies, a Challenge mode where you have to clear all triangles within a time limit, and a Shooter mode where you can blast triangles from a distance!

Report article RSS Feed Shooting Particles in Unity

For my first Unity game, I wanted to experiment with particle effects and I soon found a way to make an avatar shoot out particle fireballs. The particles looked way better than any sprites I had in mind for laser fire. Here is how I did it.

Posted by TonyYotes on Dec 23rd, 2013
Basic Animation.


For shooter mode in TriGrid, bullet sprites just didn't cut it. They were boring crystal sprites that shattered on impact. I needed something with more flare. More Geometry Wars like. I started messing with Unity's particle systems and discovered how to make a little fire ball. One color change and explosion effect later I had the shooting effect I wanted. Here is how I got those "pew pew" thingies to work.

I basically made a looping particle emitter in a cone shape using Unity's particle editor. I made it so the effect spawns up to 1000 dots that change from light blue to lavender as the die within one third of a second.


I made the particle effect it's own object, attached physics to it, and made it a trigger so that it could collide with game objects. I attached a script I named scriptShot so I could control what happens when it impacts something.

I made the particle effect it's own object, attached physics to it, and made it a trigger so that it could collide with game objects. I attached a script I named scriptShot so I could control what happens when it impacts something.

If you wanted to replicate my effect, here are the settings to do it. Releasing 130 particles at a time with an initial extra burst of 50 every time the loop resets. I made them move at a speed of 100 to get the speeding effect I wanted.


Stretching out the cone path that the particles were stuck inside was pretty simple. Unity has sliders you can adjust. To make the tail longer, all I'd have too do is increase the lifespan of each particle.


This is the method I used to make the player shoot particles. This was called every time the "Pew" button was pressed. It checks to see if less than 4 shots are already in play before firing. I wanted to limit the amount of active shots to make things more challenging. The player could shoot once in each direction if necessary, but that's it. A skilled player could possibly last forever, but triangles tend to sneak up on you and catch your flank.


This code changes the direction the player is facing. In Unity the transform.eulerAngles variable determines where an object is facing. I do this so I only have to tell the arrow to move forward when it's in motion. The player's direction determines which way the shot spawns and which way the shot moves.


The shot only knows to go forward. At the moment of its creation it checks the direction of the player and aligns itself to match it.


When it's in play, its just a matter of moving it by 4 pixels every frame in whatever direction it's facing. Based on the way the particles orient themselves, it moves by subtracting its Z-value on the coordinate plane.


After that, it was just a matter of determining what happens when it touches stuff. I made it so enemies die on contact and walls trigger the particle effect within the particle effect that plays an explosion animation and deletes the original blast. After that I save the blast and the explosion as prefabs to be summoned whenever the player taps the "Pew" button. Suddenly, I have a Shooter mode in TriGrid.

Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Icon
TriGrid
Developed By
TonyYotes
Engine
Unity
Contact
Send Message
Official Page
Yotesgames.com
Release Date
Released Oct 9, 2009
Game Watch
Track this game
Tutorial
Browse
Tutorials
Report Abuse
Report article
Related Games
TriGrid
TriGrid Single Player Arcade
Related Engines
Unity
Unity Commercial Released May 30, 2005