I am making a game where the player gets chased by lava along a road.

From the road mesh i can access the points along each side. Currently i have an edge collider that moves along these points and once it reaches the player it's game over.

My problem is that i can't figure out how to make the lava follow the edge collider. Any ideas? I am using Unity.

enter image description here

  • \$\begingroup\$ Is your perspective top-down like this, or does the lava have some appreciable depth/thickness we can see from.the side? \$\endgroup\$
    – DMGregory
    Commented Oct 17, 2018 at 12:41
  • \$\begingroup\$ @DMGregory i'ts top-down like in the picture. \$\endgroup\$
    – Tagor
    Commented Oct 17, 2018 at 22:03
  • \$\begingroup\$ create many circles and use bouncing physics material then convert them to metaball.to following player you can use movetowards \$\endgroup\$ Commented Oct 18, 2018 at 4:45
  • \$\begingroup\$ If you don't want to reinvent the wheel and are willing to pay a small amount of money, I'd go with Dreamteck Splines. Build a spline for the whole path of the lava and use the clip range slider to advance the lava. The clip range can also be calculated based on the length of the path by the library of Dreamteck splines. This video shows what I mean: youtu.be/ZnGVhQYaDII?t=71 There may very well be other libs that do the exact same thing, I'm just very happy with this one. \$\endgroup\$ Commented Oct 18, 2018 at 8:48
  • \$\begingroup\$ @McLovin thanks for the tip but my roads are procedurally generated which might be a problem with the approach you described. \$\endgroup\$
    – Tagor
    Commented Oct 18, 2018 at 19:58

2 Answers 2


Depending wether your game is 2D or 3D, there are different ways to go with this problem.

Supposing it is top-down and the lava is a sprite, maybe you can get around this issue by masking your lava with a Sprite mask : - https://docs.unity3d.com/Manual/class-SpriteMask.html

If you move your mask along with your edge collider, this should do the trick.

If your lava is a 3D object, you can add a cutout shader to it, and manipulate the "cutoff" value and settings to animate it following your edge position.

  • \$\begingroup\$ It was something like this i was looking for, thanks \$\endgroup\$
    – Tagor
    Commented Oct 18, 2018 at 19:56

You could maybe voxelize lava part of the map and form a grid. From there just use dijkstra path finding and turn it into a grid crawler. Every node on the grid is either lava or transparent. Check every frame if nodes occupied by a player are lava. Visualization of dijkstra algorithm.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .