Good afternoon people! I would like your help, how can I make the trajectory of an arrow? Something like that:

I'm still shooting the arrow right in a straight line, as you can see in the gif below:

Do you have any idea how I can do it?

Could you put the arrow(s) on a Path2D/PathFollow2d and then create a function to calculate the curve applied to the path?

yes, I'll be trying here, thanks for remembering this knot :) Later put the results ...

a month later

Hello, any idea how to stay? Someone who has tried to do?

Well, I have a rough idea on one potentially possible way I think I used at some point:

When you create a arrow scene, you have the arrow slowly rotate towards gravity, which for most projects will be downwards. You could (in theory) do something like this to get the desired effect: (not tested code!)

"We are assuming that a rotation of 0 is will have the arrow facing the ground/gravity" if (rotation > 0): rotation -= delta * IN_AIR_ROTATION_SPEED "Make sure we do not rotate too far!" if (rotation < 0): rotation = 0

Then you move the arrow based on it's rotation (using cos and sin) so as the arrow rotates towards gravity, so will it's trajectory. Once again, you could (in theory) do something like this to get the desired effect: (not tested code!)

"You may need to add/remove some from rotation so it faces the same was as your sprite" global_position += delta * MOVE_SPEED * Vector2(cos(rotation), sin(rotation))


Then in theory you could get a falling arrow. I think I did something similar for a failed prototype I made way back with Godot 2.1 (or Godot 3 before it even had it's first alpha... I cannot remember).

There are some interesting things to consider, like making sure the origin of the arrow scene is near the arrow head (so it looks like it is rotating correctly), and if you want to show the trajectory the arrow will take (like in the first GIF), you'll probably want to use some sort of algorithm to calculate the path the arrow will take instead of rotating the arrow.

Hopefully this helps!

Oh yes, thank you, I'll also test here.

13 days later

I made a small advance, but here is what I have achieved so far:

I used a RigidBody2D to create the arrow knot and a KinematicBody2D for the player.

I'm giving a better organized code, so I have not posted it yet. The next steps are to cause the arrow to rotate in the air according to Anglo, and set the sights to work. :)

4 years later