Why is test_motion not returning a collision with another RigidBody2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bitbutter

My test scene has two RididBody2Ds. The first has a script that uses test_motion to check for collisions to the right of itself. The second RididBody2D is over the the right. Behind that is a StaticBody2D. All physics nodes have their collision layer and masks at the default settings.

I have a circle node that i’m using to visualise where the collision from the test_motion call is reported. I was expecting the test_motion call to return a collision with the other RigidBody2D, but it seems to be ignoring it (reporting a collision with the wall beyond it instead). Does anyone know why?

enter image description here

extends RigidBody2D
    
    func _process(delta):
    	var result = Physics2DTestMotionResult.new()
    	var hit = self.test_motion(Vector2(30000,0),true,0.08, result)
    	if hit:
    		print(result.get_collider().name+" "+String(result.get_collision_point()))
    		$circle.set_global_position(result.get_collision_point())

Update: it seems to be a bug. Report and test file here: test_motion doesn't return collision with other RigidBody2D · Issue #43202 · godotengine/godot · GitHub

In the meantime any ideas for workarounds would be appreciated!

Activate contact monitor on your rigidbodies and contacts rep to 1

larrxi | 2020-11-02 00:17

thanks, but that hasn’t changed the behaviour.

it seems to be a bug. report and test file here: test_motion doesn't return collision with other RigidBody2D · Issue #43202 · godotengine/godot · GitHub

bitbutter | 2020-11-02 05:43

Sorry yeah it was changing the paramater infinite inertia to false that made it. I made new answer.

larrxi | 2020-11-02 06:33

:bust_in_silhouette: Reply From: larrxi

Change infinite inertia to false. I dont know but sounds like the other body not going to stop it if it has infinite inertia.

var hit = self.test_motion(Vector2(30000,0),true,0.08, result)

to

var hit = self.test_motion(Vector2(30000,0),false,0.08, result)

Thanks! (weird)

bitbutter | 2020-11-02 06:39