Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity Playmaker 2D Platformer - Enemy Hazard 2D Sprite Shape

Oct 24, 2021
About this tutorial

In this Unity Playmaker 2D Platformer - Enemy Hazard 2D Sprite Shape tutorial, I'll show how you to create an enemy hazard using the Unity 2D Sprite Shape, 2D Point Light, a Particle Effect, and animating a material. (to Join my discord server add a comment and I'll reply with the latest invite cod

Written Guide

This tutorial combines several 2D tools — Sprite Shape, a particle system, a 2D light, and animation — into one animated goo hazard the player must jump over, then wires it as an enemy that triggers game over on contact. It's a great showcase of layering effects for a polished obstacle.

Prepare the sprites and packages

Import the goo fill, edge, and bubble art and set them to Sprite (2D), point/no-filter for pixel art, with the correct pixels-per-unit (24 here). Set the fill's Wrap Mode to Repeat so it can tile, and change the goo edge's Mesh Type to Full Rect so it works as a Sprite Shape edge. Install the 2D Sprite Shape package from Package Manager.

Build the goo pool with Sprite Shape

Create a 2D Sprite Shape Profile (goo profile), assigning the fill to its Fill slot and the edge to its Edge slot. In the scene make a 2D Sprite Shape Closed Shape, assign the profile, then Edit Spline to shape it like a pool spilling from a pipe — dragging, adding, and deleting points and setting the edge height per point.

Control the fill with a custom material

The default Sprite Renderer won't let you tile the fill how you want, so create a material (goo_map), drop the goo fill into its diffuse slot, assign it as the shape's fill, and adjust tiling and offset so the texture sits right. Add a 2D point Light tinted green with a larger outer radius so the pool glows and lights nearby tiles.

Animate glow and flow

With the hazard selected, create an animation (goo anim) at 12fps. Animate the light's intensity up and back for a pulsing glow, and animate the fill material's X offset from 0 to 1 so the bubbles drift toward the player. To avoid Unity's default easing making it uneven, select the first and last keyframes and set both tangents to Linear for a steady loop.

Add bubble particles and the game-over trigger

Add a particle system, set its shape to Box, rotate it 90 so particles rise in 2D, and scale the emission box (not the transform) wider and flatter. Make a URP particles-lit material (goo bubbles) with the bubble sprite, Surface set to Transparent, tinted green to kill the white edges, and assign it in the renderer. Add a Box Collider 2D set to Is Trigger sized to the surface line, tag the pool enemy, then on the player add an enemies FSM: a Trigger 2D Event (On Trigger Enter 2D, collide tag enemy) fires game over into a state that activates the game-over UI. Now falling into the animated, glowing goo ends the game.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →