0 votes

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.

asked 4 days ago in Engine by LeereNix (16 points)

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.

Please log in or register to answer this question.

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 How to use this Q&A? before posting your first questions.