Is there a simple way to make a projectile?

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

Hello! Is there a simple way to code a projectile? I dont need any physics, just a bullet which goes straight to coursor position. The problem is, the map is moving, (charcter is always in the center, while everything else moves). And such should bullets move along with the map. It is quite simple to calculate the offset and and to the local position.
But the problem is - offset changes depending on angle and bullets have different speed. Also, by some reasons they are shoting at wrong direction.
So, is there a better way to code a projectile? Maybe with kinematic body… I did not find much tutorials on this topic.

What node are you adding the projectiles to as children? Nodes that inherit Node2D will always be positioned relative to their parent node. If they are added as children to the character, then they will “move” with the character. It might work better if you add the projectiles as children to the map node, that way they will move with the map. Also be aware that if you are getting the mouse position on the screen, it will always be relative to the top left corner of the window, so you may need to take this into account when calculating the angle that bullets need to fire at.

literalcitrus | 2018-01-14 22:42