Determine the point of the collision

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By prosta4ock
:warning: Old Version Published before Godot 3 was released.

please tell me how to determine the point of the collision?
I have a circle, I need to know there was a collision at what angle.

:bust_in_silhouette: Reply From: genete

Use KinematicBody2D and call get_collision_normal() and for the returned Vector2D calculate its angle by calling its angle() member.

:bust_in_silhouette: Reply From: ericdl

To find rigidbody2d collision info you can override the _integrate_forces function:

func _integrate_forces(state):
	if (state.get_contact_count() > 0):
		var position = state.get_contact_local_pos(0)
		var angle = state.get_contact_local_normal(0).angle()

		print("collision position: ", str(position))
		print("angle: ", str(angle))

Or you can use the rigidbody2d body_enter signal:

func _ready():
	self.connect("body_enter",self,"_body_enter")

func _body_enter(body):
	var position = body.get_global_pos() #or body.get_pos()
	print("collision position: ", str(position))