05 / 09
Packages/2D Softbody Pro/Drag & pointer input
INTERACTION & CODE
05 / 09

Drag & pointer input

Set up physical dragging with legacy input, optional Input System or a custom pointer source.

English guideSource: Unity 6000.3.13f1 · Unity Physics 2DWeb edition · 21 October 2026

Set up physical dragging#

Add one SoftBodyDragController to a scene object. Assign its camera, or tag the intended camera MainCamera. The controller selects a body using its simulated outline and applies a mass-aware grip. Release preserves momentum.

For a ready-made setup, open Demo/Drag/05-Drag.unity. The sample already includes the controller.

Choose an input route#

RouteSetup
Legacy Input ManagerThe controller supports mouse and touch when the new Input System integration is not installed or enabled.
Optional Input SystemThe separate ERAGANX.SoftBody2D.InputSystem assembly supplies SoftBodyPointerInput. Add it beside the drag controller to forward mouse/touchscreen events. This route requires the Input System package.
Custom pointer sourceConvert screen positions through the controller and call its pointer methods.

Forward a custom pointer#

StageCall
Convert coordinatesdrag.ScreenToWorld(screenPosition)
Pressdrag.BeginDrag(pointerId, worldPosition)
Movedrag.MoveDrag(pointerId, worldPosition)
Releasedrag.EndDrag(pointerId)
Disable or interrupt the input layerdrag.ReleaseAll()

Keep pointer IDs unique while active. One pointer controls one body at a time; a second pointer can control another body. Movement positions must be in world space.

The complete DragInput.cs example shows the screen conversion and press/move/release flow. Its methods are entry points for your own input source; wire the source to them and release active drags when disabling that input layer.

Adapted from the supplied guide · PDF pages 4.View source guide ↗
Keep creating.ERAGAN STUDIO.

Search a topic, setting or method across all package guides.