/unity-dev:unity-interactionfrom unity-dev
Implements press-to-use interaction for 2D and 3D Unity games: doors, switches, gates, pickups, use prompts, and point-and-click hotspots. Covers detection choice, interactor/interactable contract, and common bugs like double-press and flickering prompts.
Ships in unity-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Finding what is in reach is the easy tenth. The complaints — the prompt that flickers, the gate that opens twice, the switch used through a wall, the parcel counted twice — are never about the overlap call. They are about selecting one target and keeping it, and about who owns the change. The fix is the same in every view: the interactor selects and delivers a press; the interactable decides what the press means, and refuses on its own.
| The report | Go to |
|---|---|
| "press E to open the door", locked doors, switches, gates | §1, reference/doors-and-switches.md |
| "the prompt flickers between two objects", "I can use the switch through the wall" | reference/detection-choice.md |
| "the door opens twice" | reference/interactable-contract.md (the double-press guard) |
| "the coin gets collected twice", pickups | reference/pickups.md |
| "walk over and then use it", point-and-click hotspots | reference/point-and-click.md |
| The use prompt: placement, glyph, hold ring | reference/prompts.md |
| Which detection for this camera | §0 |
RunInput ──► interactor ──────────────► interactable ───────────► the world
(struct) who is in reach may this actor use me? gate opens, parcel counted
which ONE is selected what does using me do? events out: audio, feel, UI
spends one press on it refuses by itself
| Half | Knows | Never knows |
|---|---|---|
Interactor — resources/Interactor2D.cs, resources/Interactor3D.cs | Reach, facing, layers, the selected target, the press, the hold timer | What a switch does, whether a gate is locked, any item id |
Interactable — resources/IInteractable.cs and what derives from it | Its own state, its rule for refusing, what changes when used | Buttons, cameras, distance, what else is nearby |
One interface, one selected target, one prompt. What varies with the camera is only how the candidates are found.
By what the player points with — not by whether the project is 2D or 3D. If the project has not
named its perspective, unity-gameplay does that first.
| Perspective | The player points with | Detection | Use |
|---|---|---|---|
| Side view | Standing at it | Trigger collider on the runner + a list | Interactor2D, TriggerList |
| Top-down | The body and its facing | The same list, or a circle on a tick with a cone | Interactor2D, either mode, Facing assigned |
| Third person, overhead | The body's forward | Sphere on a 0.1 s tick, 60° cone, one line of sight | Interactor3D, Overlap |
| First person | The centre of the screen | One ray from the camera, first hit only | Interactor3D, Ray |
| Cells | The cell in front | A board lookup, no physics | Four lines in the turn handler |
| Pointer hotspots | The cursor | A hit under the pointer, then walk there | A queue of one intent |
A screen-centre ray in third person selects things the runner is nowhere near; an overlap
sphere in first person names the switch beside the one being looked at. Each row, with its
numbers: reference/detection-choice.md.
Interactable for switches and interact pickups, World for walls, Runner
for the runner. The interactor's interactable mask holds the first, blockers the second,
and the runner's layer is in neither.GateTarget on the gate, blocker assigned to its collider: opens 3 units
in 1 s, and the collider is off only in Open.GateSwitch beside a collider on Interactable, mode Toggle, the gate
dragged into targets — a reference, never a name.Interactor3D beside its RunInputSource: Overlap, range 2,
halfAngle 60. It spends RunButton.Interact in FixedUpdate.GameProbe.Register("target", () => interactor.TargetName); // "" when nothing is selected
GameProbe.Count("interactions", () => interactor.Interactions);
GameProbe.Count("gateOpens", () => gate.OpenCount);
GameProbe.SetState(() => gate.State.ToString()); // Closed · Opening · Open · Closing
templates/InteractionJourneyTest.cs, which builds its own rooms:| Test | Asserts |
|---|---|
Runner_WalksIntoReach_AndOnlyThenIsTheSwitchSelected | Nothing selected and a press ignored at 5.8 units; the switch selected by 2, never beyond |
Press_OpensTheGateOnce_AndASecondPressWhileItOpensDoesNothing | gateOpens is 1; state only goes Closed → Opening → Open; the second press is a refusal |
Switch_BehindTheRunner_IsNotSelected | In reach but 180° off the facing: no target |
Selection_HoldsBetweenTwoEqualSwitches (2D) | The runner shifts 0.1 units between mirrored switches; the selection never changes |
Press_UsesOnlyTheSelectedSwitch_AndNothingOutOfReach (2D) | One use on the selected switch, none on its neighbour, none after leaving the sensor |
INTERACTION_JOURNEY_BREAK=range, =reentry, =cone and
=flicker each turn one test red. A journey nobody has seen fail proves nothing.interactor.Target — reference/prompts.md.The depot is the same loop with Interactor2D and a trigger circle on the runner; the sorting
yard needs no interactor at all.
| The situation | Read |
|---|---|
| The interface; who owns the state change; the guard against a double press; hold and cancel; cooldown; events for audio and feel; another actor using the same switch | reference/interactable-contract.md |
| Which detection for which camera; scoring by distance and angle; priority; a prompt that flickers; a switch used through a wall; interactable layers; the cell in front | reference/detection-choice.md |
| World-space or screen-space; following the target; the glyph for the device in hand; dimmed when blocked; the hold ring; highlights | reference/prompts.md |
| Touch or interact pickups; counted twice; a magnet; back to the pool; an inventory as data; taken for good across a save | reference/pickups.md |
| A switch wired by reference; once, toggle or pressure plate; the gate's four states and its collider; locks and keys; sentries routing round a shut gate; saving it | reference/doors-and-switches.md |
| Hotspots; walk there, then act; a queue of one; overlapping hotspots; cursor verbs; gamepad and touch | reference/point-and-click.md |
| Sphere, ray and line casts; trigger flags; a query that misses | unity-physics-3d → reference/queries.md |
| Circle and point overlaps, contact filters, the list overloads | unity-physics-2d → reference/queries-2d.md |
| Which layers exist and which pairs report | unity-physics-2d → reference/layers-and-matrix.md |
The input struct, the press latch, TryUse, a scripted driver | unity-input → reference/reading-input.md |
| The pointer as a world point; a click on UI against a click on the world | unity-input → reference/pointer-and-aim.md |
| Binding display strings and glyph families | unity-input → reference/rebinding-and-devices.md |
| The cell ahead on rectangular and hexagonal boards | unity-2d-grid → reference/neighbours-and-range.md |
| Which UI system draws the prompt | unity-game-ui |
| Pools for pickups and their effects | unity-scene-flow → reference/pooling.md |
| The save file that holds "taken" and "on" | unity-scene-flow → reference/save-format.md |
| Carving a shut gate out of the NavMesh | unity-navigation |
| Walking to a hotspot in 2D | unity-game-ai → reference/pathfinding-2d.md |
| Draw order that decides the hotspot on top | unity-2d-rendering → reference/sort-order.md |
| Sound and effect stacks fired from the events | unity-game-feel → reference/feedback-stack.md |
| Journeys, the probe, proving a gate can fail | unity-play-harness → reference/journeys.md |
Copy resources/IInteractable.cs and the files the game needs into a Runtime assembly beside
RunInput.cs (unity-input → resources/), and the journey from templates/ into a PlayMode
test assembly that also references the harness. The runtime files need no package — both
physics modules are built in; the journey needs com.unity.test-framework. Components that read
fields in Awake (GateTarget) are built inactive from code, configured, then activated.
switch on the
target's type in the player script is the first step to a player that knows every object.Interact. Re-checked on every call, so a
second press, a second actor and a replay all meet the same refusal.Target; none of them runs a query of its own.range × 1.15 and make a challenger win
by 0.15, or two equal switches swap on every sway.TryUse, in FixedUpdate. Target != null && TryUse(Interact)
honours a press made just before arrival; never a device, never Update.Destroy.OpenCount == 1.Interact runs.| Not here | Go to |
|---|---|
| Damage, hit and hurt boxes, knock-back, a crate that breaks when struck | unity-combat |
| How a cast or an overlap behaves; a trigger callback that never fires | unity-physics-3d, unity-physics-2d |
| The actions asset, the reader, rebinding, the on-screen interact button | unity-input |
| Building the prompt's canvas or UXML; type size; HUD layout | unity-game-ui, then unity-ui-ugui or unity-ui-toolkit |
| The verb in another language | unity-localization |
| Moving the runner to the switch | unity-3d-controller, unity-2d-controller |
| Cell coordinates, occupancy, pushing a pickup one cell | unity-2d-grid |
| A sentry that sees, patrols or decides to use a switch | unity-game-ai |
| NavMesh obstacles, links and agents | unity-navigation |
| Pools, save files, scene loading, pause | unity-scene-flow |
| Screen shake, flashes, the sound a gate makes | unity-game-feel, unity-audio |
| The reach and open animations | unity-animation |
| Recorders, situations, the probe contract | unity-play-harness |
Dialogue trees, quest logs and shop screens are game systems built on this contract: an
interactable whose OnInteract opens them, and nothing here that models them.
reference/detection-choice.md (opens in a new tab)reference/doors-and-switches.md (opens in a new tab)reference/interactable-contract.md (opens in a new tab)reference/pickups.md (opens in a new tab)reference/point-and-click.md (opens in a new tab)reference/prompts.md (opens in a new tab)resources/GateSwitch.cs (opens in a new tab)resources/GateTarget.cs (opens in a new tab)resources/IInteractable.cs (opens in a new tab)resources/Interactor2D.cs (opens in a new tab)resources/Interactor3D.cs (opens in a new tab)resources/Pickup.cs (opens in a new tab)resources/PickupBag.cs (opens in a new tab)templates/InteractionJourneyTest.cs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tipoli5890/game-studio --plugin unity-dev51 skills in this plugin
/unity-2d-animationSkeletal 2D characters: PSB rig, bones and weights, sprite swaps, 2D IK (2D Animation package)./unity-2d-controllerMove a 2D character: platformer jump, slopes, coyote time, moving platforms, top-down movement./unity-2d-gridGrid tactics and tile puzzles, hex or square: move range, A* paths, line of sight, turns, undo./unity-2d-level2D level layout as data: Tiled/LDtk import, rooms, endless chunks, seeded levels, jump reachability.