Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity Playmaker 2D Platformer - Enemy Arm Attack Player

Nov 14, 2021
About this tutorial

In this Unity Playmaker 2D Platformer - Enemy Arm Attack Player tutorial, I'll be setting up the enemy arm to attack the player. Once you set up one of the arms then you can reuse the FSM on each of the arms with different trigger areas. (to Join my discord server add a comment and I'll reply wi

Written Guide

This tutorial gives the boss enemy's arm a full attack cycle: detect the player entering a zone, telegraph by drawing back, strike at the player's position, then reset. Because the arm is rigged with 2D IK, the whole attack is driven by tweening one object — the arm's solver target — which keeps the FSM simple and reusable for every other arm on the boss.

Build the trigger zone

Each arm gets its own attack zone. Inside the boss enemy, add a 2D sprite square, position it where the arm should react, and add a Box Collider 2D with Is Trigger checked. Name it something like arm one trigger. Tint the sprite a visible color while building — you want to see exactly where the zone sits — and turn the Sprite Renderer off once everything works.

Detect the player and draw back

On the trigger object, add an FSM starting with a Detect Player state containing a Trigger Event 2D that listens for objects tagged player. When the player enters, send an attack event into a Draw Back state. Here, tween the arm's IK target — the Solver 2D target controls the arm's placement, so moving it moves the whole arm. Use Tween Position on local position, pulling the target back (around -0.96, 0.37 in the video) with an ease out back curve over 0.3 seconds; out back nudges forward slightly before pulling away, which reads as a wind-up. Also in this state, add Get Position on the player and store it in a player position variable — you capture where the player is at this exact moment, so the strike aims at that spot.

Strike and reset

On the draw back's finished event, move to an Attack state with another Tween Position — this time in world position, targeting the stored player position, with spring easing over 0.3 seconds so the arm snaps out fast. When that finishes, a Reset Arm state tweens the target back to its original local position using ease in-out elastic over about 1.5 seconds (start at 2 and tune down), giving the arm a slower, wobblier recovery that doubles as the attack's cooldown. Its finished event loops back to Detect Player, ready for the next pass.

Make the hit register

The arm needs a collider so the player can actually be hit. On the last bone of the arm, add a Circle Collider 2D, shrink it and offset it toward the fingertip, set it as a trigger, and tag it enemy arm. The player already has an enemy hit state that listens for that tag and plays an oil-spurt particle effect on contact. Test it: the player enters the zone, the arm winds back, jets out to where the player stood, and resets — and the same logic copies straight onto the rest of the arms.

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 →