I use an area2D for a ball because Kinematic2D mades undesired behaviors for my game. I want to get the entry point of an entered body to manage bouncing. So I try to use the signal body_shape_entered. But I'm totally lost in the API of CollisionObject. And this painfully written attemps give an empty contacts list.

func _on_Ball_body_shape_entered(body_id, body, body_shape, area_shape):
	print("body ", body.name)
	var enteredShapeOwner = shape_find_owner(body_shape)
	var enteredShape = body.shape_owner_get_shape(enteredShapeOwner, body_shape)
	var contacts = myShape.collide_and_get_contacts(shape_owner_get_transform(shape_find_owner(area_shape)),
	enteredShape, shape_owner_get_transform(enteredShapeOwner))
	print(contacts)

When the scene runs the Area2D collides a segment shape, the first "print" shows that, but it seems the arguments of "collide and get contacts" are probably wrong. Thank you in advance for suggestions.

I think this might be best pushed off to processing in _physics_process

and

https://docs.godotengine.org/en/3.2/classes/class_physics2ddirectspacestate.html#class-physics2ddirectspacestate-method-collide-shape

I will recast (most) code I use for 3d for the same task

	// Physics-blah-blah should be Physics2d blah blah equivalents
	var params:PhysicsShapeQueryParameters = PhysicsShapeQueryParameters.new() //fiddle for 2d equiv
	var space_state:PhysicsDirectSpaceState = get_world().direct_space_state               // fiddle for 2d equiv
	params.transform = global_transform
	params.set_shape(your_area_s_collision_shape)
	params.collision_mask = collision_mask
	var to:Array = space_state.collide_shape(params)

The reason I suggest pushing it off to _physics_process() is because direct-space-state is only 'valid' for certain in physics_process to my knowledge. You can cache the value, but limit its use to physics_process()

Thank you for this suggestion. I made my example working just before I read you. The first argument of collide_and_get_contacts is replaced by the transform of the area2D ball as global coordinates.

func _on_Ball_body_shape_entered(body_id, body, body_shape, area_shape):
    	print("body ", body.name)
    	var enteredShapeOwner = body.shape_find_owner(body_shape)
    	var enteredShape = body.shape_owner_get_shape(enteredShapeOwner, body_shape)
    	var contacts = myShape.collide_and_get_contacts($CollisionShape2D.get_global_transform(),
	enteredShape, shape_owner_get_transform(enteredShapeOwner))
	print(contacts)

I just used stupid trial and error because I don't know what is an "owner", The docs says "it is not a node". Maybe the problem was a mess with local coordinates that mades the collision detection to miss. The last arguments doesn't need to be changed maybe because its node is at (0,0). For safety I have to make sure the transform is global.

2 years later