Give the player the ability to push and pull tagged physics objects using separate key presses. No code required — two PhysicsForceZone components and two InputKeyPress components do the work.
A PhysicsForceZone is an invisible trigger that tracks Rigidbody objects inside it and applies a force when told to. With the new Target Mode, the direction of that force is computed relative to the player — so the same component handles both push and pull depending on how it's configured.
Add two of them to the player. Wire each to a different key. Done.
Away From Target. When ApplyForce() is called, every Moveable-tagged Rigidbody inside the trigger is launched away from the player. Direction is calculated per object at the moment of the key press.
Toward Target. Same trigger radius, same tag filter — but direction is reversed. Each Rigidbody is pulled toward the player. Leave Direction Target empty and the player is found automatically by tag.
Everything lives on the player. The moveable objects are just tagged Rigidbodies — no components needed on them.
Player. The force zones use this to auto-find the player when computing push/pull direction — no manual wiring needed.Moveable (or any tag you choose — just use it consistently in the next step). Make sure each has a Rigidbody component — the force zones only affect Rigidbodies. A regular Collider (not trigger) is needed for physics to resolve.Radius to the desired reach — 3 is a good starting point.MoveableAway From Target8 / 12ImpulseoffMoveableToward Target8 / 12Impulseoff
This Key to E. In On Press Event, drag the player in, select PhysicsForceZone → ApplyForce() — choose the Push Zone (Away From Target).This Key to Q. Wire On Press Event to the Pull Zone's ApplyForce().
PushZone and PullZone.PushZone, Pull on PullZone.Radius independently on each child.ApplyForce().InputKeyPress components stay on the player — only the collider and PhysicsForceZone move to the children. The hierarchy then looks like the Two-collider variant shown in Scene Structure below.
ApplyForce() entry — Unity highlights the matching component in the Inspector so you can tell which is which. Alternatively, rename the two components in the Inspector header to "Push Zone" and "Pull Zone" for clarity.All force logic lives on the player. Moveable objects are standalone — no wiring on them at all.
Each key fires one event. That event calls ApplyForce() on the matching zone. The zone computes direction relative to the player at that instant and launches every Moveable Rigidbody inside its radius.
These are the settings most likely to need adjustment when testing. Both zones share the same fields — tune them independently.
| Field | What it does | Recommendation |
|---|---|---|
| Target Tag | Only Rigidbodies with this tag are tracked and affected | Use a dedicated tag like Moveable — don't reuse Player or Unity built-ins |
| Target Mode | Sets whether force pushes away or pulls toward the player | Away From Target = push · Toward Target = pull |
| Direction Target | The reference point for direction. Leave empty to auto-find the Player tag | Leave empty for this setup — auto-find handles it |
| Min / Max Force | A random magnitude is chosen in this range each time a force is applied | Start with 8–12 for Impulse mode; increase for heavier Rigidbodies |
| Force Mode | How the force is applied to the Rigidbody | Impulse feels snappy and responsive. Force feels gradual and wind-like |
| One Force Per Stay | Each object can only be forced once per stay if checked | Turn off for push/pull — you want to force on every key press, not just once per approach |
| Apply To First Only | If on, only the first object found in the zone is forced per key press | Leave off to affect everything in reach. Turn on if you want precise single-object selection |
| Sphere Collider Radius | The reach of the force — on the Sphere Collider, not on PhysicsForceZone | 3 units works for arm's length. Increase for a larger gravity-gun style radius |
mass. A Rigidbody with mass 100 will barely budge at force 10. Either increase Min/Max Force, or reduce the Rigidbody's mass on your moveable objects. The Rigidbody's Drag setting also affects how far objects travel after being hit.This setup is a starting point. Small changes open up different mechanics.
Away From Target, increase Min/Max Force to 20–40, and set Sphere Collider Radius to 6. Wire a single key press. Everything tagged Moveable within 6 units gets blasted outward — instant explosion effect.Apply On Enter to true on the Pull Zone and set Force Mode to Force. Objects are continuously pulled toward the player as long as they're in the trigger — no key press needed. Combine with a large radius for a gravity-well feel.Moveable. Use the push mechanic to slide it. On the pressure plate, add an InputTriggerZone with Target Tag Moveable — wire its On Enter to whatever the plate should trigger. No code, pure events.Apply On Enter to true on the Pull Zone with Force Mode Force and a small radius. Tag coins or pickups as Moveable. They'll drift toward the player when nearby. Wire an InputTriggerZone (even smaller radius) to actually collect them on overlap.Crate-tagged objects differently from Enemy-tagged objects (different forces), add additional PhysicsForceZone components — one per tag. Each zone independently tracks its own set of Rigidbodies and can be wired to any key.