Making particles follow a path

September 7 | 15

So I was tasked to make a particle system follow a set of points (P1, P2, P3, … Pn) for a visualization in the CAVE. Basically given a particle system, make the particles in it follow a set of points:












If we linearly interpolate their positions through a group of points we will get a set of particles that will follow a set of points, something like this:












Instead what we want is to make each spawned particle follow a set of directions, something like this:












So in order to achieve this, we create an array of directions (given the points), then we check the total distance traveled for each particle and then depending on where the particle is located (across the points) we change the direction accordingly towards the next point (when it reaches each point)

The end result:

The Code:

The code is pretty straight forward; one editor script and one simple script that needs to be attached to a game object that contains the particle system.

Editor Script: (remember to place it under “Editor” folder).

 The script:

Still there is some stuff missing like adding speed to the particles or making the generated pivots move relative to the game object but it pretty much does the job.



How to know if a point is inside a polygon

April 16 | 15

Here’s a quick code snippet to know if given a point, the point is inside an array of polygon vertices. Based on the crossing number algorithm.


This can also be extended to 3D space if necessary, but that’s for the reader.

Open Match-3. Developed in Unity

April 14 | 15

So I had this project for long time stored and didn’t know what to do with it so what a better idea than releasing it!.

Hopefully the community will learn from it, and if you find any better way of doing certain things I’ll be more than happy to receive some feedback!

This project is released under the MIT license, you can do whatever you want with it :).

As the title says is a match 3 that works in Unity. 4.x and 5.x. it contains:

  • Generates a move if the board doesn’t have any more moves left.
  • Supports any amount of gems (for the time being I just added 5 types of gems).
  • Works with any board size (width x height)
  • Generates an “explosion” effect when 3 or more adjacent gems are clicked.
  • Generates a hint (depending on a time in secs set in the inspector) of the largest adjacent gems.
  • Support for score multiplier when you click on several correctly adjacent gems before the hint kicks in.

Here are some screenshots of the game:

Screen Shot 2015-04-14 at 15.03.57















Also supporting any width x height (17×18) in this case.

Screen Shot 2015-04-14 at 15.05.21












Finally in order to modify certain parameters of the game, just click over the main camera object and set the desired values inside GameManager component.

Screen Shot 2015-04-14 at 15.07.54












Liked the project?, Here!, fork it!


Like this post?, feel free to subscribe to my posts, I’ll keep you posted on anything that I write :).


Any comments/suggestions/feedback let me know :).


Adding Transform.LookAt2D like it belongs to the Unity API

March 31 | 15

Unfortunately there is no Transform.LookAt2D in Unity as for now in Unity5. BUT with an extension method this can be added into the API quick and easy!.

Its pretty simple. We just need to have a namespace included wherever we want to use Transform.LookAt2D and thats pretty much!, here’s how:

Lets create the extension method for LookAt2D:

And then we just need to call it from any of our scripts as part of the Transform methods! here’s a quick example:

Quick, easy and clean!





Getting a random enum value and also be able to exclude some values

March 5 | 15

As the post says, in the game I am working on I needed to get a random value of an enumeration but on some cases I needed to exclude some values of the enumeration, so I came up with this small snippet of code that given an enum type and an array of enum excluded values it will return you a random value of the enumeration.

It works with any type of enum you create :D

If you have a better way to do it _please_ let me know :).

Quick example on how to use it: