# How to get collisions after move_and_slide() in Godot 4

After move_and_slide(), loop over get_slide_collision_count() and read each KinematicCollision2D with get_slide_collision(i): its get_collider() is what the body hit. Godot 3's get_slide_count() was renamed and fails to parse with Function "get_slide_count()" not found in base self. Did you mean to use "get_slide_collision_count()"?

Source: https://flockbay.com/godot/how-to-get-collisions-after-move-and-slide-in-godot-4/ · Updated 2026-10-30

## What Godot is checking

move_and_slide() can collide several times in one call as it slides along surfaces. Each contact is kept until the next call, and get_slide_collision_count() says how many there were.

get_last_slide_collision() returns the last one directly, and is_on_floor(), is_on_wall() and is_on_ceiling() answer the common questions without reading collisions at all.

## Reproduce it

A Godot 3 collision loop, in a Godot 4 project.

```
extends CharacterBody2D

func _physics_process(_delta):
	move_and_slide()
	for i in get_slide_count():
		print(get_slide_collision(i).get_collider())

```

## What Godot 4.7.2 prints

```
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

SCRIPT ERROR: Parse Error: Function "get_slide_count()" not found in base self. Did you mean to use "get_slide_collision_count()"?
   at: GDScript::reload (res://answers/how-to-get-collisions-after-move-and-slide-in-godot-4/repro.gd:5)
ERROR: Failed to load script "res://answers/how-to-get-collisions-after-move-and-slide-in-godot-4/repro.gd" with error "Parse error".
   at: load (modules/gdscript/gdscript_resource_format.cpp:46)
```

## Fix it

A body falling onto a StaticBody2D named Floor, reporting the first contact.

```
extends CharacterBody2D

func _physics_process(_delta: float) -> void:
	velocity = Vector2(0, 300)
	move_and_slide()
	for i in get_slide_collision_count():
		var collision := get_slide_collision(i)
		print("hit ", collision.get_collider().name, ", normal ", collision.get_normal(), ", on floor: ", is_on_floor())
		set_physics_process(false)

```

## What the fixed script prints

```
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

hit Floor, normal (0.0, -1.0), on floor: true
```

## Run this fix with your agent

Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.

```
How to get collisions after move_and_slide() in Godot 4 After move_and_slide(), loop over get_slide_collision_count() and read each KinematicCollision2D with get_slide_collision(i): its get_collider() is what the body hit. Godot 3's get_slide_count() was renamed and fails to parse with Function "get_slide_count()" not found in base self. Did you mean to use "get_slide_collision_count()"? Where this calls for a change in my Godot 4 project, make it, then run the game headless and check Godot's output for errors.
```

## Verified on Godot 4.7.2

Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.

Where the check lives in Godot's source: [gdscript_analyzer.cpp line 3767, the message with its hint](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L3767), [CharacterBody2D.get_slide_collision in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/CharacterBody2D.xml).

## Questions

### Why is the count 0 when I call it in _process()?

Collisions are from the last move_and_slide(), which runs in _physics_process(). Read them right after it.

### How do I push a RigidBody2D I walk into?

Read the collision's collider, check it is a RigidBody2D, and call apply_central_impulse(-collision.get_normal() * force).

Download Flockbay free: Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot. https://flockbay.com/download/

Related: [Could not find base class "KinematicBody2D" in Godot 4: it is CharacterBody2D now](/godot/kinematicbody2d-in-godot-4/), [KinematicBody in Godot 4: it is CharacterBody3D now](/godot/kinematicbody-in-godot-4/), [How to raycast from code in Godot 4: PhysicsRayQueryParameters2D](/godot/how-to-raycast-from-code-in-godot-4/), [PhysicsTestMotionResult in Godot 4: Identifier "PhysicsTestMotionResult" not declared](/godot/physicstestmotionresult-in-godot-4/), [Every verified Godot 4 answer](/godot/), [How do I connect Claude Code to Godot?](/docs/how-do-i-connect-claude-code-to-godot/)
