How to stuck an Area2D when it collide to Kinematic Body2D?

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

Beginner. I am currently working a game of Bow and Arrow and I want to stuck the arrow in the Dart Board. When I shoot my player and arrow just stop when it collides but it didn’t get move along to the position of Dart Board.

func _on_Arrow_body_entered(body):
  if body.is_in_group("dart_board"):
	set_process(false)

I want the if my Arrow(Area2D) enter body it will stop and stuck in the position of the DartBoard.

My Dart Board is moving using Path2D
I don’t know how to get the position of the Dartboard and put it the position of the Arrow if it collides

Does the dartboard move?

SQBX | 2023-01-05 03:45

:bust_in_silhouette: Reply From: SQBX

The movement of your arrows is probably in _physics_process. Try changing the function to this:

func _on_Arrow_body_entered(body):
  if body.is_in_group("dart_board"):
    set_process(false)

If that doesn’t work, please comment on this answer with the whole script for the arrow.

line 3 is

body.set_process(false)

Wakatta | 2023-01-05 04:47

The movement of my arrow is in my process I already solve how to stop the arrow when it collide in DartBoard. I want is if the arrow collide it will stuck in the board

Allen_Monzon | 2023-01-05 05:14

:bust_in_silhouette: Reply From: godot_dev_

If I understand correctly, you want an arrow to remain stuck in a dart board after it collides with it?

I believe this would involve reparenting the arrow after the collision is detected. You would make the arrow a child of the dartboard. If the dartboard moves, then the arrow will move with it. However, I am not sure if the appropriate position of the arrow will remain after the reparenting of the arrow. You may have to calculate relative positions and offset the arrow after reparenting it.

If the dartboard doesn’t move, then stopping the arrow after a collision should make it appear like the arrow hit and got stuck into the board.