Using test_move() vs move_and_collide()?

Godot Version

4.2.1

Question

So I’ve tried to use test_move in my AnimatableBody3D to collide with an object and do something with it. It never works but move_and_collide with the flag test_only on does! Does anybody know if I am doing something wrong?

Class setup:

extends PhysicsBody3D

var col:KinematicCollision3D;

func _ready():
	col = KinematicCollision3D.new();

Then I try to do:

if self.test_move(transform, -Vector3.UP, col, 0.1, true, maxCollisions):
		for i:int in range(col.get_collision_count()):
			var node:Node = col.get_collider(i) as Node;
			if node:
				# Do something, but this never works

but it doesn’t work! If I do:

col = self.move_and_collide(-Vector3.UP, true, 0.1, true, maxCollisions);
	if col:
		for i:int in range(col.get_collision_count()):
			var node:Node = col.get_collider(i) as Node;
			if node:
				# Do something, this does work!

It works OK!

Try using Node3D.global_transform and not Node3D.transform.

It didn’t work either :frowning: