Phaser 4 Arcade Physics
Add movement and collision to a Phaser game with the lightweight Arcade Physics engine (AABB rectangles and circles only). Targets Phaser 4.2 for new projects; inspect the installed major before editing an existing project.
When to use
- Use for top-down or platformer movement, velocity/acceleration/gravity, bouncing, world bounds, and collision/overlap resolution between sprites, groups, and tiles.
- Use when the scene enables
physics: { default: 'arcade' }and code callsthis.physics.add.*,body.setVelocity, orthis.physics.add.collider.
When not to use: the Game config, scene structure, asset loading, or
cameras → use phaser-core. Hinges, springs, complex polygons, or stacking
rigid bodies → use Matter physics (a different engine; Arcade and Matter bodies
do not interact). For engine-agnostic feel tuning see physics-tuning.
Core workflow
- Enable the world. Set
physics: { default: 'arcade', arcade: { gravity: {...}, debug: true } }in the game or scene config. Turndebugon while building to see body outlines and velocity vectors. - Give a sprite a body. Create it with
this.physics.add.sprite(...)(dynamic) orthis.physics.add.staticImage(...)(static), or attach to an existing object withthis.physics.add.existing(obj). - Drive it through the body, not by setting
x/y. UsesetVelocity,setAcceleration, gravity,setBounce, andsetCollideWorldBounds. The engine integrates position from velocity each step (already frame-rate independent). - Resolve interactions.
this.physics.add.collider(a, b)separates bodies;this.physics.add.overlap(a, b, cb)detects without separating (pickups, triggers). Pass a callback to react. - Group many objects. Use
this.physics.add.group()(dynamic) orstaticGroup()(platforms) so one collider call handles all members. - Check ground contact with
body.onFloor()/body.blocked.downbefore jumping. Run withdebug: trueand confirm bodies, contacts, and bounds.
Patterns
1. Enable Arcade Physics (game config)
2. Top-down movement (velocity from input)
3. Platformer jump (gravity + ground check)
4. Colliders vs overlaps (separate vs detect)
5. A group of moving objects
Pitfalls
- Sprite ignores physics → it was added with
this.add.spriteinstead ofthis.physics.add.sprite(orthis.physics.add.existing(obj)), so it has no body. - Setting
sprite.xdirectly fights the engine → move dynamic bodies withsetVelocity/setAcceleration. Direct position writes can tunnel through colliders. - Diagonal movement is faster → independent X and Y velocities add up; normalise the velocity vector and rescale to the intended speed.
- Platforms get pushed by the player → use a
staticGroup, or setbody.setImmovable(true)on a dynamic platform. onFloor()is always false → the body needs something to collide with; add thecollideragainst the ground/platforms before checking, and ensure gravity is on.- Moved a static body but collisions are stale → static bodies don't auto-sync;
call
body.updateFromGameObject()(orrefreshBody()on the game object). - Collider added every frame → register
collider/overlaponce increate, not inupdate.
References
- For body anatomy and tuning (drag, bounce, max velocity, custom
setSize/setCircle/setOffsethitboxes, collision categories/masks, andworldboundsevents), readreferences/bodies-and-collision.md.
Related skills
phaser-core— game config, scenes, loader, cameras (the prerequisite setup).physics-tuning— engine-agnostic feel (fixed timestep, tunneling, jitter).platformer/tower-defense— genres that compose this skill.level-design— laying out tile/platform geometry these bodies collide with.


