visible bullet after shooting

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

I mean, when we shoot, the arrow is visible until it hits the target
For example, when shooting with a bow, the arrow is visible
I read about this in Godot Document, but it was very difficult, please help me

So, are you saying, make the bullet visible, vs just using a raycast?

Millard | 2020-09-27 16:05

In any case, the arrow can be seen at the time of firing until it hits the target

abbos | 2020-09-27 16:18

Well, you see, the code will be a lot different if you’re using a raycast.

Millard | 2020-09-27 16:50

Wait for me to send you the project

abbos | 2020-09-27 16:56

Please help me very need it

abbos | 2020-09-27 17:30

:bust_in_silhouette: Reply From: Amateur.game.dev.

You could make the enemy detect when the arrow hits them, and the have the arrow become a child node of the enemy. Also, make sure to give the arrow a lower z-index so it looks like it has actually gone through them.

For this to happen you’d probably need to make the offset of the arrow so that it goes through the parent. If not, then the arrow will probably be floating which doesn’t look realistic.

https://forum.godotengine.org/9806/reparent-node-at-runtime
https://forum.godotengine.org/1754/how-to-change-the-parent-of-a-node-from-gdscript

I’m sorry, but I did not understand. Can you give an example?

abbos | 2020-09-27 14:32

Please give an example

abbos | 2020-09-27 14:47

I think Amateur.game.dev. is explaining how to make the arrow look right when it hits the enemy. However you are just trying to figure out how to shoot the arrow in the first place? Is that correct?

Millard | 2020-09-27 16:07

Hi, I have created the method of firing the bullet, I just want the bullet to be visible when firing until the bullet hits the target

abbos | 2020-09-27 16:14

What kind of node is the target?

Millard | 2020-09-27 16:22

Node is RayCast

abbos | 2020-09-27 16:40

how can the target be a raycast?

Millard | 2020-09-27 16:50

No, RayCast is not the target

abbos | 2020-09-27 16:54

ok, but i said, what kind of node is the target and you answered, Node is RayCast.

so why did i get a flag for asking how the target could be a raycast?

Millard | 2020-09-27 17:29

I made a mistake, please help

abbos | 2020-09-27 17:33

Please help me Millard please

abbos | 2020-09-27 18:03

if you want to delete the arrow, use the queue_free() function. if you only want to hide it, use the hide() function. (you can use the show() function to make it visible again. Both these functions would be on the arrow script.

does that solve your problem?

P.S. no problem about the flag, i was just looking for clarity. :smiley:

Millard | 2020-09-28 03:15

it’s really hard
Please Give an example(source code or…)

abbos | 2020-09-28 09:51

So sorry for not replying. If you don’t have an area2D then add one to the bullet. Try this:

var enemy = false
var enemyname = $enemy    

func _ready():
    if enemy == true:
        $Bulletname.queue_free()
        enemy_health = -10
func _on_Area2DBullet_area_entered(area):
    if body = enemyname:
        enemy == true

Amateur.game.dev. | 2021-01-15 17:55

Did it work?

Amateur.game.dev. | 2021-01-17 21:35