How to draw bullet sprite when using raycast2d for shooting.

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

I am making 2d shooting platformer (like cave story) and would like to use raycast2d for shooting projectile. While there are several tutorials on how to use raycast2d for shooting, there seems none for how to draw bullet sprite. I would appreciate if you could teach me how to draw a bullet sprite when shooting raycast2d.

:bust_in_silhouette: Reply From: godot_dev_

From how I understand Overwatch/first-person-shooters handle this is for raycast guns (Hitscan), the sprites/animations from shooting are purely cosmetic, although they appear extremly fast to illustrate the “speed” of the bullet, even though on the first frame of shooting the gun emits an active hitbox from gun to all the way where you aiming. For projectile hitboxes the collision shapes are tied to the sprites.

So in you case, in the above gif you include, you may want to increase the sprite projectile speed considerably if using hitscan/raycasts since the second you shoot the tip of where the projectiles reach will have a hitbox.

To summarize, make to to make your bullet animations and bullet hitboxes (raycasts) are disjoint from each other to make a hitscan bullet.