0 votes

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

Godot version I am using 3.5.1
in Engine by (16 points)

Does the dartboard move?

2 Answers

0 votes

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.

by (731 points)

line 3 is

body.set_process(false)

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

0 votes

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.

by (610 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.