5
\$\begingroup\$

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

\$\endgroup\$
  • \$\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 Oct 17 '18 at 12:41
  • \$\begingroup\$ @DMGregory i'ts top-down like in the picture. \$\endgroup\$ – Tagor Oct 17 '18 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\$ – Seyed Morteza Kamali Oct 18 '18 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\$ – McLovin Oct 18 '18 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 Oct 18 '18 at 19:58
1
\$\begingroup\$

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.

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

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.